Date: Mon, 29 Sep 1997 18:22:21 -0700 (PDT) Message-Id: <199709300122.SAA20975@adit.ap.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: jb AT netcom DOT ca, djgpp AT delorie DOT com From: Nate Eldredge Subject: Re: Printing contents of a file using C Precedence: bulk At 08:04 9/25/1997 -0400, jb AT netcom DOT ca wrote: >Hi, > >I recently posted a question: > >"I was wondering, what C code do you need to write, to make your program > >print what you want it to, during runtime? (besides pushing the Print >Scrn key)" > >and people replied. > >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? It's a simple extension of what they said: #include void dump_file_to_printer(char *filename) { int c; FILE *f; f = fopen(filename,"r" /* or maybe "rb" */ ); while ((c=getc(f)) != EOF) putc(c,stdprn); fclose(f); } You might want to add some error checks. Nate Eldredge eldredge AT ap DOT net