Mail Archives: djgpp/1997/09/29/21:24:54
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 <stdio.h>
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
- Raw text -