Output to a printer

Discussion in 'C++' started by dohboy, Mar 8, 2008.

  1. dohboy

    dohboy Guest

    Hi,
    I'm having a problem getting a program to print to my inkjet. I've tried addressing with lpt1, PRN and even USB001. It just doesn't seem to find it's way to the printer. Here's the code:

    #include <iostream.h>
    #include <fstream.h>

    int main(void)
    {
    int x = 65534;
    const double f = 3.1415;
    char somename[10];

    ofstream printer;
    printer.open("USB001");
    if (!printer) {
    cout << "There is something dodgey with the printer.\n";
    return 0;
    }

    cout<<"Enter a word (Max 9 chars): ";
    cin.getline(somename,9, '\n');
    printer << "The values are: " << x <<"\n" << f << "\n" << somename <<endl;

    printer.close();
    return 0;
    }


    Any ideas, anyone?

    TIA
    -doh

    "Ooh! sensory depravation kicks ass! "
    -The Prophet Homer
     
    dohboy, Mar 8, 2008
    #1
    1. Advertising

  2. dohboy

    red floyd Guest

    dohboy wrote:
    > Hi,
    > I'm having a problem getting a program to print to my inkjet. I've tried addressing with lpt1, PRN and even USB001. It just doesn't seem to find it's way to the printer. Here's the code:
    >


    The C++ standard ISO/IEC 14882:2003 does not discus priting, lpt1, PRN,
    or USB001. Try a newsgroup dedicated to your platform.

    That said,

    > #include <iostream.h>
    > #include <fstream.h>

    No such headers.

    #include <iostream>
    #include <fstream>
    #include <ostream>

    >
    > int main(void)
    > {
    > int x = 65534;
    > const double f = 3.1415;
    > char somename[10];
    >
    > ofstream printer;

    std::eek:fstream printer;
    > printer.open("USB001");
    > if (!printer) {
    > cout << "There is something dodgey with the printer.\n";
    > return 0;
    > }
    >
    > cout<<"Enter a word (Max 9 chars): ";

    std::cout << ...
    > cin.getline(somename,9, '\n');

    std::cin.getline
    > printer << "The values are: " << x <<"\n" << f << "\n" << somename <<endl;

    std::endl;
    >
    > printer.close();
    > return 0;
    > }
    >
    >
    > Any ideas, anyone?
    >
    > TIA
    > -doh
    >
    > "Ooh! sensory depravation kicks ass! "
    > -The Prophet Homer
     
    red floyd, Mar 9, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. yohaas
    Replies:
    0
    Views:
    534
    yohaas
    Jun 9, 2004
  2. Samuel Lee
    Replies:
    0
    Views:
    520
    Samuel Lee
    Nov 11, 2003
  3. Kyle
    Replies:
    3
    Views:
    625
    MontereySoft
    Aug 21, 2003
  4. Richard Johnson

    How to send output to a local printer

    Richard Johnson, Feb 28, 2004, in forum: C++
    Replies:
    1
    Views:
    2,468
    John Harrison
    Feb 28, 2004
  5. Replies:
    5
    Views:
    147
Loading...

Share This Page