Question: use this template code #include #include #include #include #include / / ! ! ! DO NOT CHNAGE BUFSIZE #define BUFSIZE 1 0 / * size

use this template code
#include #include #include #include #include //!!! DO NOT CHNAGE BUFSIZE #define BUFSIZE 10/* size of chunk to be read */ #define PERM 0644/* file permission for new file */ int concatFiles(const char* name1, const char* name2, const char* name3){ int infile1=-1, infile2=-1, outfile=-1; ssize_t nread, nwrite; char buffer[BUFSIZE]; if(( infile1= open(name1,___________))==-1) return (-1); if(( infile2= open(name2,___________))==-1) return (-1); if(( outfile = open(name3,_______________, PERM))==-1) return (-1); //////// Fill out this part!! -- main loop(s)//////// close(infile1); close(infile1); close (outfile); return 1; } int main(int argc, char**argv){ if(argc!=4){ printf("Usage: concatFiles file1 file2 file3
"); exit(-1); } int retcode=-1; retcode = concatFiles(argv[1], argv[2], argv[3]); }
to answer this question below
1.(50 points) Complete a function "concatFiles(const char* name1, const char* name2, const char* name3)" in the attached program template "prog.c" After its completion, name3 file will have contents obtained by concatenating the contents of namel file and name2 file. For example, if name1 file contains the following 9 characters:
ABCDMHJWP
And, if name2 file contains the following 6 characters: TUVXYZ
Then, after its execution the name2 file will contain 15 characters:
ABCDMHJWPTUVXYZ
You can only make use of the following system calls in the function implementation:
a. open()
b. read()
c. Iseek()
d. write()
e.close()
You have to complete the function definition in the attached "prog.c" file which includes main() calling dupFile("datal.txt", "data2.txt"). "datal.txt" file is also attached. Your function should use the buffer size of 10 bytes in reading and writing. Please take the following requirements into account when you create the function definition:
- namer file and name2 fle should be existent when the function is called. Otherwise, your program should exit without doing anything.
- Name3 file should not be existent when you call the function. It needs to be created as an empty file and the contents need to be filled up. If name3 file already exists, your program should exit without doing anything.
use this template code #include #include #include

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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

Students Have Also Explored These Related Programming Questions!