Mail Archives: djgpp/1997/09/26/00:45:26
jb AT netcom DOT ca wrote:
> Now what I want to know is, can I tell the program to print the contents
> of a specified file during runtime? if so, how, using what C code?
There are many, many ways of doing this, but here is my preferred method:
int main(void)
{
	FILE *infile = fopen("test", "rb");
	char *input = (char *)NULL;
	if(!(input = (char *)malloc(1024))) abort();
	while(fgets(input, 1023, infile) != EOF) {
		fprintf(stdprn, "%s", input);
	}
	
	return(0);
}
-- 
[- 				 firewind	                            -]
[-   email: firewind AT metroid DOT dyn DOT ml DOT org (home), firewind AT aurdev DOT com (work)  -]
[- 	    "You're just jealous because the voices talk to -me-."          -]
- Raw text -