CS 420 - Assignment 2

Due Thursday, September 20th by 11:59 PM

In this assignment, you will write a file copy program using only OS-level API functions.

Your Task

Your program should take two command line arguments.

The first is the name of an input file, and the second is the name of the output file.  The program should open both files (the input file for reading and the output file for writing) and copy the entire contents of the input file into the output file.

If the entire copy operating is successful, the program should exit with an exit code of 0.

If an error occurs, the program should print an error message to the standard error file descriptor and exit with a non-zero exit code.


Your program must use only OS-level API functions.  Specifically, you may use any POSIX functions under Linux (or other Unix variant) or Win32 functions under Windows.  [If you would like to use a different OS-level API, let me know.]

For POSIX, you will be using functions such as open, close, read, and write.

For Win32, you will use functions such as CreateFile, ReadFile, and WriteFile.

You must not use any I/O functions from the standard C or C++ libraries.  These include functions like printf, fprintf, fopen, fread, fwrite, fclose, etc., and also the iostream facility in C++ (cin, cout, cerr, etc.)

You may use C, C++, or assembly language to implement your program.  (Making direct calls to system-level API functions is difficult in languages like C# and Java.)

Sources of Information




Extra Credit

You can earn 20% extra credit by writing your program so that it issues system calls directly instead of using API functions.  This will require some assembly language programming.  (I can give you more information if you are interested in trying this.)


Please include a document explaining how you implemented your program, what sources of information you used, and what API functions you used.


Create a zip file containing both the source code to your program and your report.  [If you used Visual Studio, please include the entire Visual Studio solution in your zip file.]

Upload the zip file to the Marmoset server:


Use the user name and password you received by email.  Submit as Project 2.