Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/*
2
 * pANS stdio -- fgets
3
 */
4
#include "iolib.h"
5
char *fgets(char *as, int n, FILE *f){
6
	int c=0;
7
	char *s=as;
8
	while(n>1 && (c=getc(f))!=EOF){
9
		*s++=c;
10
		--n;
11
		if(c=='\n') break;
12
	}
13
	if(c==EOF && s==as
14
	|| ferror(f)) return NULL;
15
	if(n) *s='\0';
16
	return as;
17
}