#ifndef _READLINE_H_ #define _READLINE_H_ #include /* * Procedure: * readLine * Parameters: * infile, a pointer to a FILE * str, a string (a pointer to a character) * max, an integer * Purpose: * Read up to max-1 characters from the current line, * stopping when you hit end of line, end of file, * or too many characters. * Produces: * read-successful, an integer * Preconditions: * infile is "valid" (refers to a file that contains text, * currently open, readable, ) * infile must contain either (1) at least max-1 additional * characters, (2) a newline, or (3) EOF. * max must be at least 1. * str must refer to at least max consecutive characters * of allocated space. * Postconditions: * str should contain at most max-1 characters just read * from infile (in the order in which they were read). * str contains a string-terminator ('\0') in the first * max characters. * If readLine read max-1 non-EOF/non-EOL characters, * read-successful is 0. * If readLine read a newline character, the stream is * now positioned immediately after that character. * Otherwise, read-successful is 1. * At most max-1 characters have been read from infile. * infile is still open for reading. */ extern int readLine(FILE * infile, char *str, int max); #endif /* _READLINE_H_ */