Assignment 5 : CIS 208

Assigned: March 3rd, 2004
Due: March 11th,    by 5:00 PM.  

Turn in hard copies to the CIS Main office and
email your source code (not compiled programs) to sdg5476@ksu.edu.

This assignment is worth 10 points.

Write a C program that does the following:
Read in 'little endian' binary numbers from a file, convert these numbers into decimal
and print the value to a new file.

Specifically:
1) The user should give the name of the input file as a command line argument.
2) The output file is the name of the input file + ".out"  e.g.:
input = test.dat
output = test.dat.out
3) If the input file does not exist, then tell the user and exit the program.
4) All input files for this program will have a specific format.  Each line has one binary number sequence.
There are no empty lines, or extra characters.
5) Each binary number is in 'little endian' style, or that the least significant bit is first.

1 == 1
01 == 2
001 == 4
0011 == 12
etc.

6) Every binary number is a positive whole number.
7) There is no restriction on pointer or array use.  Use whichever you think is better.


Note: It's pretty hard to dynamically allocate just enough memory to store strings coming from
a file. Instead, i would suggest creating a buffer that you know will be large enough to hold each line.
Let's say each line is no more than 80 characters long.
Make sure that you close any files and free any allocated memory. 

Sample Input files
test1.dat
test2.dat

Example input/output
%> assign5 test1.dat
%> more test1.dat.out
9
12
1
4
15
%>

Note: 'more' is a unix program that quickly displays the contents of a file.

%> assign5
Give a file name.
%>