/* File: list-io.c * Author: Jim Mayfield */ /* This package provides input and output routines for lists of integers. For both input and output, lists are represented as sequences of integers within angle brackets (e.g. <1 2 3>). Read_int_list takes a FILE * as its argument and reads one list from that stream. If a legal list specification is not found, read_int_list prints an error message and returns as much of the list as it was successfully able to read. This means that if the first (non-whitespace) character read is not '<', the_empty_list will be returned AND NO INPUT WILL BE CONSUMED. Thus, if another attempt is immediately made to read a list, the same error will occur. Print_int_list takes a FILE * and a list as its arguments, and prints the list to the given stream using angle bracket notation. No carriage return is printed. To use the package, you will need to follow the instructions in the file "lists.h", taking care to typedef list_item_type to be int. Then, include "list-io.h" after your inclusion of "lists.h": typedef int list_item_type; #include "lists.h" #include "list-io.h" */ #ifndef _LIST_IO_HEADER_ #define _LIST_IO_HEADER_ void print_int_list(FILE *outfile, list_type list); list_type read_int_list(FILE *infile); #endif