Misallocation
Test your C programming skills by solving the given puzzle about pointer mismanagement.
We'll cover the following...
Puzzle code
...Press + to interact
#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){struct raw { int value; char string[32]; };FILE *outfile;struct raw *data;data = malloc( sizeof(struct raw) );data->value = 60;strcpy( data->string, "This is a string\n" );outfile = fopen("data.dat","w");if( outfile==NULL )exit(1);fwrite(data, sizeof(data), 1, outfile);fclose(outfile);puts("File written");free(data);return(0);}
...