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
include stdioh include fcntlh FILE lopen char char ... View full answer
Get step-by-step solutions from verified subject matter experts
Document Format (1 attachment)
34-E-CE-OS (390).docx
120 KBs Word File
