I've been away from programming for a while, and fear that I may have over-indulged in some form of brain killing activity...If one of you good people would be kind to point out what I'm doing wrong with this (simple) program, I'd be most gratefull...
Code:
#include <stdio.h>
#define STR_SIZE sizeof(struct TEST)
#define C_SCANF while(getchar() != '\n');
struct TEST{
char msg[100];
int number[2];
}msg[10];
int main(void)
{
int count = 0;
FILE *fp;
if ( (fp=fopen("test.TXT","rt+"))== NULL)
{
if ( (fp=fopen("test.TXT","wt"))== NULL)
{
printf("\nUnable to create test file");
return 1;
}
}
while(count < 10)
{
printf("\nEnter a message > ");
fgets(msg[count].msg,800,stdin);
printf("\nEnter a number (I don't care) > ");
scanf("%d", msg[count].number);
C_SCANF;
fseek (fp,(count)*STR_SIZE, SEEK_SET);
fwrite(&msg,STR_SIZE,1,fp);
count++;
}
}
Thanks for any help..