Starting from:
$35

$29

Programming Assignment 1 Solution

Objective
The objective of this assignment is to familiarize yourself with the standard system calls and how to use them in a program.

Assignment: Simple File Concatenate Program
Write a C/C++ program that only uses only standard system calls to concatenate the contents of one file to another file. You should only have to use the open(), close(), read() and write() system calls. You can use printf() or fprintf() for error or informational messaging.  Your program should not explicitly prompt the user for input/output filenames but rather those should be provided on the command line.

Simple File Concatenate Program Implementation
The file concatenate program (filecat.c) is a simple text-based program that takes two arguments from the command line, again no prompting the user from within the program.

 

1.      To start the filecat program

 

./filecat <input file <output file

where <input file is the file to be concatenated to <output file. Note: that <output file can be an empty file or a file with previous contents. To make debugging easier use ASCII readable text files only.

After your program completes you should be able to do a “cat” command on the <output file to verify it has been concatenated. Last step is to run your program with strace to determine the number/type of system calls made.

Error Handling
Perform the necessary error checking to ensure that the input file exists and that the output file can be written. You can use the system error “errno” and “strerror” to provide additional error messaging.

Grading
The program will be graded on the basic functionality, error handling and how well the implementation description was followed. Be sure to name your program filecat.c (no extra characters, capitals) and include the output from the strace command. Note that documentation and style are worth 10% of the assignment's grade!

Submission
The program (source code only) should be posted to Blackboard on the due date

More products