:confused: How would I print enough blank lines to an output file when the data file has an unknown number of entries? ( I can have multiple arrays on a page, but output for an individual array can not be split between two pages.):confused:
Printable View
:confused: How would I print enough blank lines to an output file when the data file has an unknown number of entries? ( I can have multiple arrays on a page, but output for an individual array can not be split between two pages.):confused:
there aren't any pages in a text file. Try opening something large in Notepad (or the Linux equivalent... KWrite, maybe)
when you print a large file even in Notepad, it still will print on multiple pages...my printer prints 65 lines/page.
Yes, but in the file itself it doesn't have a concept of seperate pages. You usually need to tell your printer to form feed, by sending it a ^L character.
For instance you may set the program up with a page size of 65 lines, once 65 lines have been printed - send the form feed.
But I guess it depends on what platform/compiler your using because I am sure the Win32 API for example has a more elegant method.
Sorry - I had just been doing shell scripts - ignore the ^L, it should be '\f'..
You should send the form feed character for C/C++ which is of course '\f'.
I am not near a compiler right now, but I snarfed this code from a site that should do what you want.
EDIT: This code assumes that your printer is connected on port LPT1, if you are on a network, you can reference the printer using the network pathname.. something like "//PRINTERHOST/PRINTER"Code:#include<iostream>
#include<fstream>
using namespace std;
int main(void)
{
cout << "Started" << endl;
ofstream printer1;
printer1.open ("LPT1", ios::out);
for (int count = 1; count <= 65; count++) // to fill page
{
printer1 << "testing" << endl;
}
printer1 << '\f' << endl; // form feed
printer1.close();
cout << "Finished printing to LPT1 " << endl; // finished
return 0;
}
Thank you, that helped a lot :D
I appreciate it.