Structures, Unions, Enums

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

A Yes

B No

ANS:A - Yes

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.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.