Question: Do in C programming language in linux environment. cannot use library functions, only system calls such as open() Create the following function: int convert_copyfile(const char*

Do in C programming language in linux environment. cannot use library functions, only system calls such as open()

  • Create the following function:
    • int convert_copyfile(const char* name1, const char* name2)
    • this function should return the number of conversions made (the to THE).
  • If the target file (second argument) doesnt exist, then your program should create an empty file for writing.
  • If the target file (second argument) exists, then your program should exit with error message without doing anything.
  • Use the combination of option flags in open() system call we covered in the class.
  • Use BUFSIZE=100 to iteratively read bytes from the input file and write converted bytes into the output file. (Use while loop as in the example program.)
  • While reading bytes, you should
    • Keep track of the number of occurrences of the word in the file. (Case sensitive)
  • While writing bytes to the output file, you should
    • Replace any occurrence of the word with THE word.
    • Then, write back the modified contents to the output file.
  • Create main() function which makes the following call:
    • Convert_copyfile(assign2_input.txt, assgn2_output.txt);
  • Print out the total number of conversions made (from the to THE);

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 Databases Questions!