Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
  2. #include <stdio.h>
  3. #include <libc/file.h>
  4.  
  5. char * fgets(char *s, int n, FILE *f)
  6. {
  7.  int c=0;
  8.  char *cs;
  9.  cs = s;
  10.  while (--n>0 && (c = __getc(f)) != EOF)
  11.  {
  12.   *cs++ = c;
  13.   if (c == '\n') break;
  14.  }
  15.  if (c == EOF && cs == s) return NULL;
  16.  *cs++ = '\0';
  17.  return s;
  18. }
  19.