www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/24/02:01:42

From: pjfarley AT dorsai DOT org (Peter J. Farley III)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Printing on the printer
Date: Wed, 24 Sep 1997 01:57:06 GMT
Organization: None
Lines: 28
Message-ID: <342872c0.5802270@snews.zippo.com>
References: <34282F89 DOT B19A9F61 AT netcom DOT ca>
NNTP-Posting-Host: news.newsdawg.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

jb AT netcom DOT ca wrote:
<Snipped>
>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)

Use "PRN:" as the filename.  Try this:

#include <stdio.h>
#include <errno.h>

main()
{
    FILE *prntr;

    if ((prntr = fopen("PRN:", "w")) == NULL) {
        printf("Error %d! %s: %s\n", errno, "PRN:", strerror(errno));
        exit(1);
    }

  fprintf(prntr, "This appears on the printer,\nthen a page feed\f");
    fflush(prntr);
    fclose(prntr);
    exit(0);
}

----------------------------------------------------
Peter J. Farley III (pjfarley AT dorsai DOT org)

- Raw text -


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