Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c language Assignment #2 Due Feb 11 @ midnight Given a file (Asson Linput.txt); a given. Create a program with the following functionality. (based on

image text in transcribed
image text in transcribed
image text in transcribed
c language
Assignment #2 Due Feb 11 @ midnight Given a file ("Asson Linput.txt"); a given. Create a program with the following functionality. (based on exon pg. 20) o use BUFSIZE=512 to iteratively read/write bytes from the input file. Luse while a loop as in the ex. program) 2 while reading byres, - find number of occurrences of the a Bremet word in the file (case sensitives a while writing lytes replace the occumence of "the " word with "THE" word. Then write modified contents to the output file - print out output file contents at the end of the program - print out the number of "the " occurrences. Submit your code, text file. - screenshot showing running of program Lincluding compilation) * must include indentation a comments 15 of 179 20 The fle 2.1.8 The copyfile sample We are now is the position to tackle our first practical example. The task is town a function copyile which will copy the contents of one file to her Themen value should either bezero indicating SOS, or a s ative number indicate The basic logic is clear open the first file, then create the second read from the first and write to the second until the end of the first is reached Finally close both The finished solution might look something like copyile - Copy nael to name21 include cunistd.h> include centi.h> Idefine BUPSITE de tine PER 512 0644 site of chunk to be read / / tile permission for new file. A copy a to na 2 / Int copyrile const char nanel, const char 2 int intile, outiles Set hread char buffer BUPSIDE) ) - 1) II intile-open namel, ORDONLY return (-1); if(loutile pennel, WRONLY|O_CREATI_THON, PER - 1) closetitill: now read from BOSTEE chans at a time. whilet read readintile, butter, write batter to output file. If I write outfile, better. sed head close intile: closelottile) retur -3) write error close tinute: eloselottile) ) thread return (-4): error on last read else return (0) ; /* all is well / copyfile can now be used with a call like: retcode - copyfile("squarepeg", "roundhole")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions