CS 2213 Advanced Programming, Fall 2000 Lab Assignment 3


Due Thursday, October 12, 2000

Lab Assignment 3 has 3 parts.


Part 0:
Get all of the files from /usr/local/courses/cs2213/fall2000/lab03 and put them in a clean directory.

You should have the files getline.c, getline.h, and makefile. The file getline.c contains most of the code for the getLine function.

Write a main program in getlinetest.c which uses getLine to read a line from standard input and print it out.

Recall the getLine returns a line with no characters when an end of file is reached and returns NULL when an error occurs. In each of these cases the main program should print an appropriate error message.

Your program should start by printing a line indicating your name. It should then use getLine to get a line and either print it out or print an appripriate error message.

Do not modify getLine for this part of the assignment.


Part 1:
The getLine function in Part 0 is incomplete since it does not do any reallocation when the input line is too long. Fix this problem. (We did (or will do) this in class.) Instrument the getLine program so that it prints a message when it determines that reallocation is necessary. This message should contain the current character read and the space left. Print another message after the reallocation has been done indicating the amount of space left after reallocation.

Run lint and make sure you understand all of the messages produced.

Test your function using the main program from Part 0. You should not have to modify this main program.


Part 2: Handing in your results
Run your program from Part 1 with input lines of length 0, 8, 9, 10, and 11. (This length includes the newline, but not the string terminator.) Use cut and paste to send the output to cs2213 as part of a mail message with subject line:
cs 2213 lab assignment 3 results

Be sure that you use cut and paste. Do not send your results as an attachment which assumes a particular type of mail reader.

Note that you can create an input line of length 0 by type CTRL-D when the program expects input. To type CTRL-D, hold down the Control key and push the D key.


Note: Do not change the value of INIT_ALLOC in the function.