Thread: Printer problem?

  1. #1

    Unhappy Printer problem?

    I am having trouble printing a report generated by a program i have created. I want to print a hard copy of this report to my printer but it just will not work. Below is all the instructions I have tried, can anyone help me out please. I am using Borland C++.


    I have checked help and it says that the streams I have used above are opened automatically. I have tried the above in conjunction with the fopen function and the tried the fprintf but nothing seems to work!!!!!PLEASE HELP ME!!!!!!!!!


  2. #2
    Registered User
    Join Date
    Jan 2002
    You can't use standard streams as far as I'm aware,
    you need to define a FILE pointer with an appropriate name, then open the stream 'manually'.

    Try something like this:

    FILE *prn_fp;

    /* some code */

    if( ( prn_fp = fopen( "LPT1", "w" ) ) == NULL )
    /* error code here */

    then fprintf( prn_fp, ........ );

    If LPT1 doesn't work try "PRN"

    LPT1 and PRN are used in Dos, and this works for me using Visual C++ to compile C programs.

    Hope this helps

    Foffo Spearjig

    PS You can use freopen() to redirect std streams if you want, but I can't comment on this, having never used it!
    Last edited by Foffo Spearjig; 01-24-2002 at 12:31 PM.

  3. #3
    Code Warrior
    Join Date
    Nov 2001


    I only wrote this for printing on "LPT1":

    fprintf(stdprn, "\n\r Hello");
    Maybe it's not the problem in your code, maybe it's your printer.

    That's all folks.
    Last edited by GaPe; 01-26-2002 at 12:56 PM.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  2. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  3. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  5. binary tree problem - help needed
    By sanju in forum C Programming
    Replies: 4
    Last Post: 10-16-2002, 05:18 AM