Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. #include <stdio.h>
  2. #include "conio.h"
  3. #include <errno.h>
  4.  
  5. char *fgets(char *str, int n, FILE *stream)
  6. {
  7.     int i=0, sym_code;
  8.  
  9.     if(!stream || !str){
  10.         errno = EINVAL;
  11.         return NULL;
  12.     }
  13.    
  14.     while (i<n-1){
  15.         sym_code = fgetc(stream);
  16.         if(sym_code =='\n' || sym_code == EOF){ break; }
  17.         str[i]=(char)sym_code;
  18.         i++;
  19.     }
  20.    
  21.     if(i<1){ return NULL; }
  22.     return str;
  23. }
  24.