1. Run on infile1.dat and infile2.dat
$ ./sortEmployees input/infile1.dat input/infile2.dat outfile
Reading File 1: input/infile1.dat
Name Salary
---- --------
Joe Schmoe 45000
Flo Schmoe 55000
Bo Schmoe 77000
Mo Schmoe 66000
Reading File 2: input/infile2.dat
Name Salary
---- --------
Ada Lovelace 44000
Grace Hopper 55000
Alan Turing 40000
Result:
Name Salary
---- --------
Ada Lovelace 44000
Alan Turing 40000
Bo Schmoe 77000
Flo Schmoe 55000
Grace Hopper 55000
Joe Schmoe 45000
Mo Schmoe 66000
Number of total employees: 7
Average salary: $54571.43
One way to check if your output file is correct is to run the wc
command to count
the number of bytes in the file:
$ wc input/infile1.dat input/infile2.dat outfile 2 8 70 input/infile1.dat 0 6 59 input/infile2.dat 2 14 129 outfile
This shows that the output file is 129 bytes, which is the sum of the number of bytes in the two input files (70 and 59).
Another way to test your output file is to try using it as input to another run of your program.
2. Run using output file as input
If you are correctly creating the binry output file, you should be able to use the output file from one run as input file to other runs:
$ ./sortEmployees outfile input/infile2.dat outfile2 Reading File 1: outfile Name Salary ---- -------- Ada Lovelace 44000 Alan Turing 40000 Bo Schmoe 77000 Flo Schmoe 55000 Grace Hopper 55000 Joe Schmoe 45000 Mo Schmoe 66000 Reading File 2: input/infile2.dat Name Salary ---- -------- Ada Lovelace 44000 Grace Hopper 55000 Alan Turing 40000 Result: Name Salary ---- -------- Ada Lovelace 44000 Ada Lovelace 44000 Alan Turing 40000 Alan Turing 40000 Bo Schmoe 77000 Flo Schmoe 55000 Grace Hopper 55000 Grace Hopper 55000 Joe Schmoe 45000 Mo Schmoe 66000 Number of total employees: 10 Average salary: $52100.00 $ ./sortEmployees outfile outfile2 outfile3 Reading File 1: outfile Name Salary ---- -------- Ada Lovelace 44000 Alan Turing 40000 Bo Schmoe 77000 Flo Schmoe 55000 Grace Hopper 55000 Joe Schmoe 45000 Mo Schmoe 66000 Reading File 2: out2file Name Salary ---- -------- Ada Lovelace 44000 Ada Lovelace 44000 Alan Turing 40000 Alan Turing 40000 Bo Schmoe 77000 Flo Schmoe 55000 Grace Hopper 55000 Grace Hopper 55000 Joe Schmoe 45000 Mo Schmoe 66000 Result: Name Salary ---- -------- Ada Lovelace 44000 Ada Lovelace 44000 Ada Lovelace 44000 Alan Turing 40000 Alan Turing 40000 Alan Turing 40000 Bo Schmoe 77000 Bo Schmoe 77000 Flo Schmoe 55000 Flo Schmoe 55000 Grace Hopper 55000 Grace Hopper 55000 Grace Hopper 55000 Joe Schmoe 45000 Joe Schmoe 45000 Mo Schmoe 66000 Mo Schmoe 66000 Number of total employees: 17 Average salary: $53117.65
3. Run using large files
Here is a run on two large files from `~newhall/public/cs44/lab01` showing just part of the output:
$ ./sortEmployees ~newhall/public/cs44/lab01/input300.dat ~newhall/public/cs44/lab01/input400.dat outfile Reading File 1: /home/newhall/public/cs44/lab01/input300.dat Name Salary -------------------- -------- Gabriel R. Vernay 66000 Zendaya S. Young 214000 ... Laila B. Dvorak 141000 Reading File 2: /home/newhall/public/cs44/lab01/input400.dat Name Salary -------------------- -------- Bai D. Rosenberg 170000 Vasyl H. Gallo 87000 ... Isak O. Unger 110000 Result: Name Salary -------------------- -------- Ada K. Kipkirui 225000 Ada N. Olsen 111000 Ada U. Unger 126000 Ada W. Hassan 241000 Ada Y. Ito 132000 Akira F. Barbosa 225000 ... Zola O. Xiao 113000 Zola W. Adve 85000 Zuri A. Zsiga 74000 Zuri J. Dvorak 135000 Zuri W. Young 207000 Zuri Y. Tytovsky 256000 Zuri Z. Quigley 149000 Number of total employees: 700 Average salary: $164132.86