I'm trying to assign value to my_record
but the compiler keeps indicating that my line my_record->x = counter;
is having an error:
uninitialized local variable 'my_record' used.
#include<stdio.h>
typedef struct rec
{
int x, y, z;
} *abc;
int main()
{
int counter;
FILE *ptr_myfile;
//struct rec my_record;
abc my_record;
ptr_myfile = fopen("test.bin", "wb");
if (!ptr_myfile)
{
printf("Unable to open file!");
return 1;
}
for (counter = 1; counter <= 10; counter++)
{
my_record->x = counter;
fwrite(&my_record, sizeof(abc), 1, ptr_myfile);
}
fclose(ptr_myfile);
system("pause");
system("pause");
return 0;
}