Question: Consider the program as shown below. The C stdio library provides a similar set of file operations using the FILE data structure for a file

Consider the program as shown below. The C stdio library provides a similar set of file operations using the FILE data structure for a file description. Rewrite the simple file copy example in the figure using the C stdio library routines rather than the UNIX kernel routines.

#include

#include

int main () {

int inFile, outFile;

char *inFileName = “in_test”;

char *outFileName = “out_test”;

int len;

char c;

inFile = open (inFileName, 0_RDONLY);

outFile = open (outFileName, 0_WRONLY);

/* Loop through the input file */

while ((len = read(inFile, &c, 1)) > 0)

write (outFile, &c, 1);

/* close files and quit */

close (inFile);

close (outfile);

}


Step by Step Solution

3.43 Rating (162 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

include stdioh include fcntlh FILE lopen char char ... View full answer

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

Document Format (1 attachment)

Word file Icon

34-E-CE-OS (390).docx

120 KBs Word File

Students Have Also Explored These Related Computer Engineering Questions!