Hi!!!I need some help!!!
I have written the following code:
Code:
#include <stdio.h>
struct info
{
float mo;
int age;
}m;
int main()
{
int il;
FILE *fp;
fp=fopen("sx.txt","rb");
if (fp==NULL){
printf("Problem!!!\n");
exit(0);
}
fseek(fp,4,0);
fread(&m,sizeof(struct info),1,fp);
printf("Age:%d\n",m.age);
rewind(fp);
fread(&m,sizeof(struct info),1,fp);
printf("Age:%d\n",m.age);
return 0;
}
and put at the file the following numbers:
5 18
8.5 21
10 20
3 18
6 19
The first printf("Age:%d\n",m.age); does not give me the right result(19)..Why????