Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke

4th Edition

0136086535, 9780136086536

More Books

Students also viewed these Databases questions

Question

A rating instrument linked to job duties and responsibilities

Answered: 1 week ago

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago