ECE-1021

HOMEWORK #3

(Last Mod: 27 November 2010 21:38:38 )

ECE-1021 Home


Working with Data Representations and Data Files.

Download the program hw#3start.c from the course website (see the Example Code page) and use it to generate two data files. You may also want to download the file filedump.c from the website in order to be able to examine the byte-by-byte contents of these files.

Notice that there are two sections of code at the bottom of hw#2.c that are bypassed through the use of #ifdef statements. You can activate these sections of code by uncommenting the corresponding #define statement at the top of the code.

In the first of these sections of code there is a block of statements that, if properly ordered, will read the text file and reproduce its contents on the screen. Your job is to unscramble the lines so that they do this. You are NOT to modify the lines in any way, delete them, nor add any additional lines. This, of course, only applies to the file you eventually turn in. You are free to do whatever you want as you work.

You will notice a character (which may be a space) at the end of each line. When they are properly ordered, those characters will form a vertical sentence. As you work, these characters should start to give you some clues as to how to proceed. There is more than one correct way to order the statements, but as you get close to a viable solution parts of the sentence should start becoming discernable. Use this to try to reconstruct the original sequence of statements.

In the second section you will also find a list of statements that are out of order. Ordering these should be considerably easier than the previous section but before you reorder them, examine the contents of the data file and determine why the program generates the output that it does.

The code that you will submit for grading is simply the unscrambled program but be sure that it has the proper file name, header, and contents in the comment sections.