EECS 2031 Software Tools, Winter 2014

Lab 6 (lab open during first 30 minutes, then closed in labtest mode)

Cellphones and other electronic devices must be off while you are in the lab.

Background Scenario

This lab uses the same bathroom scale data transmission scenario as lab2 to lab5. Corrected: However, this time you have to adapt your solution to handle arbitrarily long input.

In the following and for ease of reading, the changes relative to lab6 have been marked below with '***'. As before, each line of input contains the following information:

timestamp userID weight

There are one more space characters separating the three pieces of information, except that the userID itself may now contain one or more spaces (as in "1000 John Jack Smith 123.45"). The fields are defined as follows:

This protocol can be parsed deterministically, as the weight is the first numeric field after a sequence of text fields, e.g. as in timestamp userIDa userIDb userIDc userIDd weight and none of the parts of the userID can start with a digit or '.'.

Objective

Now create a new ANSI-C program that does the following.

Requirements

Your program must the input read line by line from standard input. For the purpose of this lab, you do not need to worry about numeric overflow. In other words, you can safely assume that timestamps are guaranteed to fit in 32 bit integers, and floating point numbers will fit into a ANSI-C float variable. You can also safely assume that there is always at least one (or more) space characters between the fields and between each part of the userID.
*** However, in this lab there is no limit on the line length for the input, nor for the length of the userID.

Here is an input file with long lines, input.txt. If you start your program with this, you should get the following output attached again as a file expectedoutput.txt.

Hints:

Additional hints: