-
Can this be done?
How would you write this code using C stdio library routines instead of the UNIX kernel routines?
Code:
#include <stdio.h>
#include <fcntl.h>
intmain()
{
int inFile, outFile;
char *inFileName = "in_test";
char *outFileName = "out_test";
int len;
char c;
inFile = open(inFileName, O_RDONLY);
outFile = open(outFileName, O_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);
}
Thanks for your help.
-
fopen() instead of open()
fclose() instead of close()
fwrite() instead of write()
fread() instead of read()
-
and probably
"r" instead of O_RDONLY
"w" instead of OWRONLY