To: djgpp AT delorie DOT com Subject: output to printer with streams Message-ID: <19970209.041157.12278.0.john.k.murphy@juno.com> References: From: john DOT k DOT murphy AT juno DOT com (John K Murphy) Date: Sun, 09 Feb 1997 05:16:55 EST Well thanks for the replies showing me how to output to the printer using fprintf(), it worked: I had just never tried it that way. Here is the way I found and unsuccessfully attempted before: Can this method, using the streams, ever work? (it was in a tutorial on C++) Everything works in this program except for opening and outputting to the printer. // Chapter 1 - Program 4 - FSTREAM.CPP #include #include #include void main() { ifstream infile; ofstream outfile; ofstream printer; char filename[20]; cout << "Enter the desired file to copy ----> "; cin >> filename; infile.open(filename, ios::nocreate | ios::in); // "| ios::in" had to be added by me if (!infile) { cout << "Input file cannot be opened.\n"; exit(1); } outfile.open("copy"); if (!outfile) { cout << "Output file cannot be opened.\n"; exit(1); } printer.open("LPT1", ios::nocreate | ios::out); if (!printer) { cout << "There is a problem with the printer.\n"; exit(1); } cout << "All three files have been opened.\n"; char one_char; printer << "This is the beginning of the printed copy.\n\n"; while (infile.get(one_char)) { outfile.put(one_char); printer.put(one_char); } printer << "\n\nThis is the end of the printed copy.\n"; infile.close(); outfile.close(); printer.close(); } // Result of execution // // (The input file is copied to the file named "COPY") // (The input file is printed on the printer