kandr/ch1/longest_line.c
int mygetline(char s[], int lim) {
  int c, i;

  for (i=0;(c=getchar()) != EOF && c != '\n'; i++) {
    if (i < lim-1)
      s[i] = c;
  }
  if (c == '\n') {
    s[i] = c;
    i++;
  }
  s[i] = '\0';
  return i;
}
/* mygetline: read a line into s, return length */
read a line into s, return length
read a line into s return length
int mygetline(char s[], int lim) {
  int c, i;
  for (i=0;(c=getchar()) != EOF && c != '\n'; i++) {
    if (i < lim-1)
      s[i] = c;
  }
  if (c == '\n') {
    s[i] = c;
    i++;
  }
  s[i] = '\0';
  return i;
}
int mygetline ( char s [ ] , int lim ) { int c , i ; for ( i = 0 ; ( c = getchar ( ) ) != EOF && c != ' \n ' ; i ++ ) { if ( i < lim - 1 ) s [ i ] = c ; } if ( c == ' \n ' ) { s [ i ] = c ; i ++ ; } s [ i ] = ' \0 ' ; return i ; }
mygetline: read a line into s, return length
mygetline : read a line into s return length