954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

c++ print on paper

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

scream2ice
Light Poster
33 posts since Mar 2008
Reputation Points: 10
Solved Threads: 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

Perhaps output to a file then printing the file :)

joshmo
Posting Whiz in Training
280 posts since Oct 2007
Reputation Points: 19
Solved Threads: 20
 

>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
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

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

scream2ice
Light Poster
33 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
 

This may be relevant.

Jishnu
Posting Pro
518 posts since Oct 2006
Reputation Points: 193
Solved Threads: 25
 

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
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You