Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Programming Problems 2.26 In Section 2.3, we described a program that copies the

ID: 3870179 • Letter: P

Question

Programming Problems 2.26 In Section 2.3, we described a program that copies the contents of one file to a destination file. This program works by first prompting the user for the name of the source and destination files. Write this program using either the Windows or POSIX API. Be sure to include all necessary error checking, including ensuring that the source file exists. Once you have correctly designed and tested the program, if you used a system that supports it, run the program using a utility that traces system calls. Linux systems provide the strace utility, and Solaris and Mac OS X systems use the dtrace command. As Windows systems do not provide such features, you will have to trace through the Windows version of this program using a debugger

Explanation / Answer

You have to install first this packages on Ubuntu based operating system because i am usnig Ubantu OS.

sudo apt-get install build-essential manpages manpages-dev manpages-posix manpages-posix-dev

If you named this file file_copy.c and if you want to name executable file file_copy to compile this program you would probably this:

gcc -Wall -o file_copy file_copy.c

To run type following:

./file_copy source_file.txt destination_file.txt