/* * File: * readline.c * Author: * Samuel A. Rebelsky * Version: * 1.0 of March 2003. * Summary: * An implementation of the readLine procedure from CSC195 Exam 2. */ /********************************************************************* * Headers * ***********/ #include #include #include "readline.h" /********************************************************************* * Exported Procedures * ***********************/ /* See readline.h for documentation. */ int readLine(FILE *file, char *str, int max) { int i; /* Counter variable. */ int ch; /* Character read. */ for (i=0; (i < max-1) && ((ch=getc(file)) != '\n') && (ch != EOF); i++) str[i] = (char) ch; str[i] = '\0'; return ((ch == EOF) || (ch == '\n')); } /* readLine(FILE *, char *, int) */