Thread: accessing printer

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    8

    accessing printer

    Hello,

    hope somebody can just point me in the right direction.

    For all of my projects I've just been saving output whch is to be printed, to a text file. And later printed it out using note pad or word pad.

    I know that there must be a way of me actualy controling the printer myself but have no idea how.

    This has no bearing on my studies, I just realy need to know.

    The compiler that I'm using is "Dev C++", and the printer I'm trying to access is "lexmark Z42".

    Is this about controling the port that the printer is using or do I have to interact with the printers own driver?


  2. #2
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212
    This works for text only and black and white.

    Code:
    #include <stdio.h>
    
    int main(void)
    {
            FILE *prnt = fopen("LPT1", "w");
            if (prnt == NULL) {
                    printf("Cannot open printer.\n");
            } else {
                    fprintf(prnt, "Hello, printing world!\n");
                    fclose(prnt);
            }
            return 0;
    }
    Last edited by Brian; 10-19-2003 at 11:32 AM.

  3. #3
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    Some compilers define stdprn to be the printer output device. Look in stdio.h to see if it's defined, or simply try it.

    Note that this would not be standard C
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Set Printer Prior To Loading Print Dialog Box
    By Beaner in forum Windows Programming
    Replies: 3
    Last Post: 10-10-2008, 01:02 PM
  2. Accessing printer & touchscreen in Linux
    By g4j31a5 in forum C++ Programming
    Replies: 5
    Last Post: 08-08-2006, 02:04 AM
  3. changing property (layout) of a printer
    By leojose in forum Windows Programming
    Replies: 5
    Last Post: 12-05-2005, 07:16 AM
  4. Success - Output to Printer
    By noraa in forum C Programming
    Replies: 5
    Last Post: 08-04-2002, 09:12 AM
  5. Replies: 0
    Last Post: 04-30-2002, 07:24 PM