Home » C Programming » Structures, Unions, Enums

If the following structure is written to a file using fwrite(), can fread() read it back successfully? struct emp { char *n; int age; }; struct emp e={"CuriousTab", 15}; FILE *fp; fwrite(&e, sizeof(e), 1, fp);

Correct Answer: No

Explanation:

Since the structure contain a char pointer while writing the structure to the disk using fwrite() only the value stored in pointer n will get written. so fread() fails to read.

← Previous Question Next Question→

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion