From: firewind Newsgroups: comp.os.msdos.djgpp Subject: Re: Printing contents of a file using C Date: 26 Sep 1997 02:09:29 GMT Organization: Netcom Lines: 24 Message-ID: <60f5gp$rfj@dfw-ixnews3.ix.netcom.com> References: <342AFC04 DOT EF643D3 AT netcom DOT ca> NNTP-Posting-Host: elp-tx3-03.ix.netcom.com Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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-." -]