Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Tasks: The Chapter 2 lecture slides describe a program that copies contents of one file to a destination file. It first prompts the user
Tasks: The Chapter 2 lecture slides describe a program that copies contents of one file to a destination file. It first prompts the user for the name of the source and destination files. In this assignment, we will write a program that will allow us to copy multiple files to a destination file sequentially. Write this program in C or Java. Make sure that the program includes all necessary error checking (e.g., that the source file exists, etc.). Hint: For multiple files, think of loops when reading and writing to files to reduce code redundancy. The sequence of system calls for this program is shown below. This sequence copies multiple source files to a destination. Example system Call Sequence Acquire how many source files will be used (n) Accept Input Loop (n amount of times) Acquire input file name Write prompt to screen Accept Input Check if source file exists, if not abort Acquire the output file name Write prompt to screen Accept Input If output file exists, abort else create the file Loop (n amount of times) Open input file Loop Read from input file Write to output file Close input file Close output file Write completion message to screen Terminate normally Example: - Take 2 input files named file1.txt with content "This is the first text file" and file2.txt with "This is the second text file". Your destination file final.txt should contain the following: This is the first text file This is the second text file Once you have written and tested the program, run the program using a utility that traces system calls. Linux systems provide the strace utility whereas Solaris and Mac OS have the dtrace utility. On Windows, you will have to trace the program using a debugger or your IDE.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started