Get Started
990

Q: 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 = { "Sujay",15}; FILE *fp; fwrite (&e, sizeof (e), 1, fp);

  • Show Answer
  • Workspace

Answer :
Explanation :

No, since the structure contains a char pointer while writing the structure to the disk using fwrite() only the value stored in the pointer n would get written. When this structure is read back the address would be read back but it is quite unlikely that the desired string would be present at this address in memory

The Most Comprehensive Exam Preparation Platform

Get the Examsbook Prep App Today