All pastes #939509 Raw Edit

Something

public text v1 · immutable
·published 2008-03-12 10:49 UTC
rendered paste body
char *mygetline(char *line, int size)
{
   if ( fgets(line, size, stdin) )
     {
       char *newline = strchr(line, '\n'); // check for trailing '\n' 
       if ( newline )
	 {
	   *newline =  '\0'; // overwrite the '\n' with a terminating null 
      }
     }
   return line;
}