Fall 2017 CSCI 235 Homework — C file programming 1

This assignment must be uploaded as a C program to C file programming homework on moodle by 5:15 PM on October 27.

Problem 1 and only

Transforming input to output

First, download a sample input file for this assignment. Each line of the input file contains the name, location, and enrollment of a university similar to that shown below.

UNC Asheville, Asheville, 3821

Your task is write a crash-free C program that reads a file, in the format shown above, and prints it, in neatly formatted columns.

For example, suppose the input contains the following two lines.

UNC Greensboro, Greensboro, 19647
North Carolina Central University, Durham, 8094

Then the output should look something like the following:

North Carolina Central University            Durham              8094
UNC Greensboro                               Greensboro         19647

Assume that the input file contains 1000 or less lines. For the purposes of making your output align neatly; you may assue that no university name or location contains a comma, that no university name is longer than 50 characters, that no university town is longer than 20 characters, and that no university has more than 1073741824 students.

Running your program

Write your program so that it can be run from the command line (on a Linux system) with at least one of the following commands.

./CollegePrint input-file
./CollegePrint input-file output-file

In the first case, where no output file is given, the output of your program should be writen to the file cp-out.txt.

If the program is run with no arguments or with an “improper” file name, your program should print an appropriate error message before exiting. Your program should silently ignore improperly formatted input lines.

File submission

Submit either a .zip, .tar, or .tar.gz for this assignment. Your submission can contain either a compressed NetBeans project or the Makefile and C files for this assignment.