Consider the program as shown below. The C stdio library provides a similar set of file operations
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 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);
}
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Question Posted: