0

hi,
does anyone know if there is a code in c++ that allows print on paper instead of monitor?

i mean instread of using 'cout<<' to see what you want on monitor, use a code to print your info on paper.......cheers

5
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by Duoas
Featured Replies
  • 1
    Narue 5,707   8 Years Ago

    >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. Read More

  • 3
    Duoas 1,025   8 Years Ago

    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: [code=C++] #include <fstream> #include <iostream> using namespace std; int main() { ofstream printer( "prn" ); if (!printer) { cout << "fooey!\n"; … Read More

1

hi,
does anyone know if there is a code in c++ that allows print on paper instead of monitor?

i mean instread of using 'cout<<' to see what you want on monitor, use a code to print your info on paper.......cheers

Perhaps output to a file then printing the file :)

Comments
thnx
1

>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.

Comments
thnx
0

i use Microsoft Visual C++ 6.0
and my operating system is Windows XP

3

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!

Comments
thnx
Great post, and sorry for giving you crap when I first joined.
This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.