The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 399 Weeks Ago, 1 Day Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
This is a warm-up program. Write a program to read a file (source) and then copy certain bytesof this file to the other file (target) with some data modification. The requirements are below:1. Take command line arguments (source file name, target file name, and a number for totalbytes to read/write).2. Use system calls (open(), read(), write(), close() ) to deal with files.3. Use char array as buffer, and the size of each buffer is limited to 80 200. For example,char buf[80]; in your program.4. Each time before read, call sequence( ) function, which returns an integer between 41 and80, to get the number of bytes to read and then write to the target file.Note that the function sequence() is defined in the file /asu/prog01/prog01.h on classmachine 147.97.156.244. The sequent() function returns integer between 41 and 80.5. Add 111 to the number immediately following “IDX” in the contents of source file. Forexample, IDX123 in the source file is changed to IDX234 in the target file; IDX56 in thesource file is changed to IDX167 in the target file. (If no number followed by IDX, thenno change is needed.) Note that IDX### are always inside a “”.6. Write the data to the new file only up to the number obtained from the command lineargument. (If user specified number is less larger than the size of source file, then workfor the whole source file.)7. Make sure length of file name is less than 80 and contains only alphabet or numericalvalues.
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll