GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 07-Sep-2005, 14:47
Salchester Salchester is offline
New Member
 
Join Date: Aug 2005
Posts: 2
Salchester is on a distinguished road

Printing Problem!


I have just mastered how to print a file for a program I am making. Only, when it has finished printing, the printer stops without giving me the printout.

It must think there is more to print, but there isn’t. How do I let it know it has finished so I can have the printout.

Many Thanks
Coding Enclosed…

P.s can I print from USB rather than LPT1?

CPP / C++ / C Code:
#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
#include <conio.h>
#include <ctype.h>
#include <dos.h>

int main (void)
{
  char name[20];
  char house;
  int amount;
  amount = 0;
  ifstream data (".\\data.txt");
  ofstream printer ("LPT1");
  printer << "data.txt" << endl;
  printer << "------------------------------------------" << endl;
  do
  {
    data >> name;
    data >> house;
    printer << name << " ";
    printer << house << endl;
    amount++;
  } while (!data.eof());
  printer << "------------------------------------------" << endl;
  printer << " Records in file: " << amount << endl;
  printer << "------------------------------------------" << endl;
  printer.close(); // is this correct?
  return 0;
}
Last edited by LuciWiz : 08-Sep-2005 at 06:39. Reason: Please insert your C code between [c] & [/c] tags
  #2  
Old 07-Sep-2005, 15:01
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,372
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Output a form feed (0x0C) as the last character before closing the printer.
__________________

The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
  #3  
Old 07-Sep-2005, 15:35
Salchester Salchester is offline
New Member
 
Join Date: Aug 2005
Posts: 2
Salchester is on a distinguished road

Printing Error!


Quote:
Originally Posted by WaltP
Output a form feed (0x0C) as the last character before closing the printer.

Where/how do i put 0x0C in the coding?
How do you close the printer?

Many Thanks
  #4  
Old 07-Sep-2005, 17:13
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,372
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by Salchester
Where/how do i put 0x0C in the coding?
The same way you output any value to the the printer...
As for where, I already told you -- Just before you close the printer.

Quote:
Originally Posted by Salchester
How do you close the printer?
Isn't your line
CPP / C++ / C Code:
printer.close();
closing your printer? Or am I missing something?


Quote:
Originally Posted by Salchester
I have just mastered how to print a file
For a "master" at printing, these seem to be "novice" questions... Are you having problems you haven't told us about?
__________________

The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
 
 

Recent GIDBlogProblems with the Navy (Officers) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Graphic problem in Unreal Tournament 2004 zerox Computer Software Forum - Games 10 09-Oct-2005 12:31
a significant problem after installing Xp mohammad Computer Software Forum - Windows 10 09-Aug-2005 07:03
problem printing output iamsodumb C++ Forum 4 10-Mar-2005 13:19
Printing problem Frandy MS Visual C++ / MFC Forum 1 16-Feb-2005 13:47

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 07:54.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.