Discussion :: 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={"Freshergate}; FILE *fp; fwrite(&e, sizeof(e), 1, fp);
Answer : Option B
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.
Be The First To Comment