Join Examsbook
987 0

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 AnswerHide 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

Are you sure

  Report Error

Please Enter Message
Error Reported Successfully