View Single Post
Old 09-07-2005, 10:20 AM   #1 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
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?

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;
}
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote