Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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?

Note: I need the answer in this format:

| Label | Address | Value |

| i | 400 - 403 | 5 |

#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);

}

===============================

Write out the file contents for out2 as produced by the following code. Give specific values to bytes or ranges of bytes. The values of the same variable are being written using fprintf() and then fwrite(). How many bytes are written by each, and which is more efficient?

#include

main() {

FILE *fpt;

struct frog {

float d;

int x;

} henry;

henry.d=12.73;

henry.x=81925;

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

fprintf(fpt,"%7.2f %7d ",henry.d,henry.x);

fwrite(&henry,sizeof(struct frog),1,fpt);

fclose(fpt);

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

c. What groups were least represented? Why do you think this is so?

Answered: 1 week ago

Question

7. Describe phases of multicultural identity development.

Answered: 1 week ago