cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/29/21:24:54

Date: Mon, 29 Sep 1997 18:22:21 -0700 (PDT)
Message-Id: <199709300122.SAA20975@adit.ap.net>
Mime-Version: 1.0
To: jb AT netcom DOT ca, djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: Printing contents of a file using C

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019