FILE *read1stline(char line[], int lengthline, char *filename)
{
int c; /* input character */
int i = 0; /* counter in a for loop */
FILE *fp; /* pointer to open file */
/* open the file */
fp = fopen(filename, "r");
/* read the first line, or up to EOF, whichever comes first */
while((c = getc(fp)) != EOF && c != `' && i < lengthline)
line[i++] = c;
/* smack on a nul byte */
line[i] = `\0';
/* return the file pointer */
return(fp);
}
Send email to
cs153@csif.cs.ucdavis.edu.
Department of Computer Science
University of California at Davis
Davis, CA 95616-8562