Question: I have the following code where i have to replace the xxxxxxxxxxxx with the correct argument to run the code. I have no idea what
I have the following code where i have to replace the "xxxxxxxxxxxx" with the correct argument to run the code. I have no idea what these commands are or what the syntax is due to poor instructors.
Please help
#include
int main(int argc, char *argv[]) { int const BUF_SIZE=10; int const EXTRA_SIZE=5; int inputFd, outputFd, openFlags; mode_t filePerms; ssize_t numRead; char buf[BUF_SIZE]; char buf1[EXTRA_SIZE]: char* inputFileName="input.txt"; char* outputFileName="output.txt";
inputFd = open(inputFileName, O_RDONLY); if (inputFd == -1) printf("opening file %s", inputFileName);
openFlags = O_CREAT | O_WRONLY | O_TRUNC; filePerms = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; /*rw-rw-rw */ outputFd = open(outputFileName, open Flags, filePerms); if (outputFd == -1) printf("opening file %s", outputFileName);
while ((numRead = read(inputFd, buf, BUF_SIZE)) > 0) { if (write(outputFd, xxxxxxxxxxxxxxxxxx, numRead) != numRead) printf("couldn't write while buffer"); if (write(outputFd, "EXTRA", xxxxxxxxxxxx) != EXTRA_SIZE) printf("couldn't write while EXTRA buffer"); } if (numRead == -1) printf("read");
if(close(inputFd) == -1) printf("close input"); if(close(outputFd) == -1) printf("close output");
inputFd = open(outputFileName, xxxxxxxxxxxxx); if (inputFd == -1) printf("opening file %s", outputFileName);
while ((numRead = read(inputFd, buf, BUF_SIZE)) > 0) { if (write (1, xxxxxxxxxxxxxxxxxxx, xxxxxxxxxxxxxxxxxxx) != numRead) printf("couldn't write whole buffer"); read(inputFd, buf1, 5); } write(1, " ", 1); if (close(inputFd) == -1) printf("close input");
return(0); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
