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
Bookmarks