Results 1 to 5 of 5

Thread: help on turbo c++ printing text file

  1. #1
    Join Date
    Jul 2009
    Posts
    2

    smile help on turbo c++ printing text file

    I am new to prog in c++ and new to this forum too....

    Nice to get acquainted. Like to start seeking help right away

    I made following program in turbo c++ but not able to print on my HP lasserjet 1015 printer installed on DOT4_001 port -- I get message unable to open port DOT_001.........Plz help find error


    void main(void)

    {
    clrscr();

    char filename[13];

    char ch;

    cout<<"\nEnter the text file name:";

    cin.getline(filename,13);

    cout<<"\n";

    ifstream fin(filename, ios::in);

    if(!fin)
    {
    cerr<<"\n Cannot open file !\n";
    getch();
    return;
    }

    char const * const PrinterName = "DOT4_001:"; // Identify the printer port.
    ofstream printer(PrinterName); // Open the printer stream.
    if(!printer) // Ensure the printer stream opened ok.
    {
    cerr << "\a\n\tERROR: Unable to open " << PrinterName << endl;
    cout << "\n\tPress the [ENTER] key to return ";
    getch();
    return;
    }

    while (! fin.eof())

    {

    fin.get(ch);
    printer << (ch);

    }
    printer << endl << ends << flush;

    printer.close(); // Finish the print job by closing the printer stream.
    fin.close();


    // Send a carriage return and a formfeed to the printer so that: a) this
    // print job is ejected from the printer, and b) the next print job starts
    // at the top left corner of the page.

    fin.close(); // Close file./
    cout << "\n\n\t\t\t\Printing...";
    cout << "\n\n\ Please press the [ENTER] key to return";
    getch();

    return;
    }



    thanks

  2. #2
    Join Date
    Oct 2005
    Posts
    75

    Re: help on turbo c++ printing text file

    Welcome to Techarena india forums, Always try to post the thread in correct section.

    Thread Moved.

  3. #3
    Join Date
    Feb 2008
    Posts
    283

    Re: help on turbo c++ printing text file

    Welcome to Techarena Community.

    I would like to ask you if your HP laserjet 1015 printer is installed properly with its drivers & its working properly for your normal print function through your operating System? IF yes then your code must be the problem but I dont think so.

    May be using a parallel cable from the PC to the printer help you, or use a dot matrix printer.

    Please have a look at http://msdn.microsoft.com/hi-in/maga...67(en-us).aspx
    I hope this helps you.

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: help on turbo c++ printing text file

    If you have any protection software turned on in the computer, just disable it. Windows also has protection that you have to disable Temporarily.If you have Norton, right click on the icon that is down on the toolbar and click disable and answer "yes" to any pop up window asking "if you are sure". Now try to print on HP lasserjet 1015 printer installed on DOT4_001 port.

  5. #5
    Join Date
    Jul 2009
    Posts
    2

    Re: help on turbo c++ printing text file

    I would like to add that the printer is installed properly and works with all other applications.

    thanks

Similar Threads

  1. Replies: 5
    Last Post: 17-03-2011, 08:01 PM
  2. How to convert image text into a text file
    By Wadee in forum Windows Software
    Replies: 5
    Last Post: 02-12-2010, 06:33 PM
  3. How I Restrict Printing and Text Copy from my web page?
    By Banjiji in forum Technology & Internet
    Replies: 4
    Last Post: 25-01-2010, 04:14 PM
  4. Printing Text File Direct To Printer
    By Vineeta in forum Software Development
    Replies: 2
    Last Post: 31-08-2009, 06:40 PM
  5. scheduled printing of a text file using batch files or schtasks
    By Gadgetman in forum Windows XP Support
    Replies: 10
    Last Post: 12-06-2008, 11:48 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,854,300.53139 seconds with 17 queries