Question: 1)Write out the memory map and file contents for the following code, providing all values at the end of execution. What is the exact output

1)Write out the memory map and file contents for the following code, providing all values at the end of execution. What is the exact output produced by this program?

#include

main() {

double testd;

int testi;

FILE *fpt;

struct frog {

double *x,y;

};

struct frog turtle,*apple,tv[3];

testi=21;

apple=&turtle;

turtle.y=5.2;

fpt=fopen("out3","w");

fwrite(apple,sizeof(struct frog),1,fpt);

fclose(fpt);

apple->x=&testd;

fpt=fopen("out3","r");

fread(&(tv[1]),sizeof(struct frog),1,fpt);

fclose(fpt);

*(turtle.x)=7.3;

(*apple).y=3.6;

turtle.y=1.5;

*(tv[1].x)=6.4;

printf("%lf ",tv[1].y);

}

======

2)Consider the variable declaration below. Write code that opens a file for output and uses a single line of code to write out all of the declared variable(s). struct inventory {

char name[30];

int count;

float price;

} log[75];

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!