display | more...
This is a function that can be easily created in C in order to obtain a line from an input stream without the terminating newline character. It performs the same function as the C++ istream::getline().

#include <stdio.h>

int fgetline(char str[], int maxlen, FILE *fp)
   int last;
   if(!fgets(str, maxlen, fp))
      return -1;
   last = strlen(str)-1;
   if(str[last]=='\n') str[last] = '\0';
   return 0;

Log in or register to write something here or to contact authors.