vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

fgets.c (247B)


      1 #include <stdio.h>
      2 
      3 char *fgets(char *s, int size, FILE *f)
      4 {
      5 	char *p = s;
      6 	char *ep = s + size;
      7 
      8 	if (size < 1)
      9 		return NULL;
     10 
     11 	while (p < ep-1) {
     12 		int c = fgetc(f);
     13 		if (c == EOF || c == '\n')
     14 			break;
     15 		*p++ = c;
     16 	}
     17 	*p = 0;
     18 	return s;
     19 }
     20