Function reads from a file stream pointed to by 'fp' and stores characters until the '
' or EOF character is found, the resultant string is returned.
Note that neither '
' nor EOF character is stored to the resultant string, also note that if on a line containing useful data that EOF occurs, then that line will not be read in, hence must terminate file with unused line.
{
char *line = new char[MAX_LINE];
if (fgets(line,MAX_LINE,fp)==NULL)
return NULL;
line[MAX_LINE-1] = '\0';
int len = strlen(line);
while (len>0 && (line[len-1]=='\n' || line[len-1]=='\r'))
line[--len]='\0';
return line;
}