Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1)Write out the file contents for out.txt as produced by the following code. Give specific byte values. How many total bytes will the file contain

1)Write out the file contents for out.txt as produced by the following code. Give specific byte values. How many total bytes will the file contain at the end of execution?

#include

main() {

FILE *fpt;

int x;

fpt=fopen("out.txt","w");

for (x=0; x<15; x+=2)

fprintf(fpt,"%2d ",x);

fclose(fpt);

}

2)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

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions

Question

=+Does it make you feel cool?

Answered: 1 week ago