inappropriate output while readin the content of a file
i wrote a program which performs the following functions:
1> read the content.
2> display the content.
in my second part, the out put i am getting is not appropriate. my code snippet for the display function:
Code:
void display(void)
{
FILE *fp;
fp= fopen("details.txt", "r");
if(fp==NULL)
{
printf("cannot open file");
getch();
exit(0);
}
rewind(fp);
printf("\n");
while(fread(&emp, sizeof(struct _emp), 1, fp)==1)
printf("%s\t\t\t%d\t%f", emp.name, emp.age, emp.salary);
getch();
fclose(fp);
return;
}