ftell fseek II (sva)

Garrett Wollman wollman at emily.uvm.edu
Tue Dec 18 07:29:27 AEST 1990


Hmmm...

-----begin frgets.c----
/* WARNING: typed from memory, untested on this machine */

#include <stdio.h>

static char *frgets_help(FILE *fp,int len) {
	int c = fgetc(fp);
	char *res;

	if((EOF == c) || ('\n' == c)) {
		char *res;
		if(res)
			res[len] = '\0';
		return(res);
	}

	if(res = frgets_help(fp,len+1))
		res[len] = (char)c;

	return(res);
}

char *fgrets(FILE *fp) {
	return(frgets_help(fp,0));
}

------end frgets.c-----

-GAWollman
	
Garrett A. Wollman - wollman at emily.uvm.edu

Disclaimer:  I'm not even sure this represents *my* opinion, never
mind UVM's, EMBA's, EMBA-CF's, or indeed anyone else's.



More information about the Comp.lang.c mailing list