Printing in C++

Hey i want to print from a printer with C++. As i understand it all you have to do is set up the printer as a file stream and do it, but how? Of course i could be wrong to begin with...


A confused 11th Grader
- Altheric

Comments

  • : Hey i want to print from a printer with C++. As i understand it all you have to do is set up the printer as a file stream and do it, but how? Of course i could be wrong to begin with...
    :
    : A confused 11th Grader
    : - Altheric
    :
    Here are a couple of simple methods:

    #include
    main()
    {
    fprintf(stdprn, "a line of text
    ");
    }

    or

    #include
    main()
    {
    FILE *stream;

    stream = fopen("PRN", "w");
    fprintf(stream, "a line of text
    ");
    }

    depending on the compiler and libraries being used you would need to check your documentation for referencing the printer.

    It could be 'stdprn', "PRN", "LPT1", or "LPT2" and so on.

    Hope this helps.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion