>does anyone know if there is a code in c++ that allows print on paper instead of monitor?
Communicating with specific hardware is outside the bounds of standard C++. If you want a good answer, you need to tell us what compiler you're using and your operating system.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
If all you want is teletype output (like you get on the console, without any fancy graphics or fonts or etc) you can open the PRN or LPT1 device:
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
ofstream printer( "prn" );
if (!printer)
{
cout << "fooey!\n";
return 1;
}
printer << "Hello world!\n";
printer.close();
return 0;
}
Most PC printers that I know of can handle simple TTY output of this kind. If you open in binary mode you can also send printer control codes (specific to your printer) to program it.
Have fun!
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229