Thread: Code for Printing to printer

  1. #1
    Registered User joshjane123's Avatar
    Join Date
    Feb 2016
    Posts
    8

    Code for Printing to printer

    need code for print. that when you execute i will automatically print to a printer

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,667
    Which OS?
    Which Compiler?
    Which Printer?

    Are you writing console programs, or GUI programs?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User joshjane123's Avatar
    Join Date
    Feb 2016
    Posts
    8
    hmmmm console sir
    os = windows 7 and 8
    gnu gcc compiler
    then to any printer

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,667
    Depending on how your compiler is configured, you may be able to do this
    [code]
    fprintf(stdprn,"Hello World\n");
    fprintf(stdprn,"\f"); // form feed, print the whole page now
    [/code

    Or you may need to do this
    Code:
    FILE *fp = fopen("LPT1:","a");
    fprintf(fp,"Hello World\n");
    fprintf(fp,"\f");  // form feed, print the whole page now
    This should work if you have a printer attached directly to the PC, but if it's some network printer or USB printer, then things might be a bit trickier.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Printing with printer
    By g4j31a5 in forum C++ Programming
    Replies: 5
    Last Post: 09-14-2006, 01:06 PM
  2. Printing the program to a printer
    By zombie in forum C++ Programming
    Replies: 2
    Last Post: 01-31-2005, 05:31 PM
  3. Printing Debug Without Printer :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 10-15-2002, 02:18 PM
  4. Printing to a printer....I already did a search :)
    By fastmonkey in forum C++ Programming
    Replies: 1
    Last Post: 10-09-2002, 01:51 AM
  5. printing on network printer
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 10-21-2001, 02:10 PM