#Solution void main() { struct student { char name[30], - TopicsExpress



          

#Solution void main() { struct student { char name[30], rollno[6]; }stud; FILE *fp = fopen(“somefile.dat”,”r”); while(!feof(fp)) { fread(&stud, sizeof(stud), 1 , fp); puts( stud.name); } } Explanation: fread reads 10 records and prints the names successfully. It will return EOF only when fread tries to read another record and fails reading EOF (and returning EOF). So it prints the last record again. After this only the condition feof(fp) becomes false, hence comes out of the while loop. #Akshay kumar
Posted on: Thu, 03 Oct 2013 12:48:23 +0000

Trending Topics



Recently Viewed Topics




© 2015