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;
7
	char *s=as;
8
	c = EOF;
9
	while(n>1 && (c=getc(f))!=EOF){
10
		*s++=c;
11
		--n;
12
		if(c=='\n') break;
13
	}
14
	if(c==EOF && s==as
15
	|| ferror(f)) return NULL;
16
	if(n) *s='\0';
17
	return as;
18
}