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;
}