Thread: how do i print the screen?

  1. #1
    Registered User
    Join Date
    Nov 2001

    how do i print the screen?

    is there any c++ code that allows me to print the screen?

  2. #2
    Registered User
    Join Date
    Nov 2001
    if you mean print in text mode try this

    #include <iostream.h>

    void main()
    cout << "I am printing to the screen";

    the #include directive with <iostream.h> is necessary for using the cout statement.


  3. #3
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    I do believe that "print the screen" means print the screen to the default printer. Yes you can do it. It takes a lot more code than you are probably ready for though.

    This is a sampling of what 'just' writing to the the parallel port involves... it doesn't include reading the video buffer, etc.

    #include <conio.h>
    #include <stdio.h>
    int _outp( unsigned short port, int databyte );
    // This program accepts an input from the user
    // in decimal and outputs that number as an 8-bit
    // binary number to the port at 378 hex, usually
    // LPT1
    int main () {
    	int inval = 0;
    	while ( inval < 256) {
    	  printf("Enter a value in decimal (256 to quit)>");
    	  scanf("%d", &inval);
    	  _outp(0x378, inval);
    	_outp(0x378, 0);
    return 0;

  4. #4
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Or as I like to call it... "The right way." hahahah

    #include <iostream>
    #include <fstream>
    #include <stdlib>
    using namespace std ;
    int main()
            char printer[10] = "LPT1:";
            char character;
            ofstream prnt (printer);
            if (! prnt) 
                    cout << "ERROR-Unable to open " << printer << '\n' ;
                    return 1 ;
            system ("cls");
            cout << "Type the text you wish to have printed.  You must use "
                 << "\nyour own returns as there is no text wrapping other than "
                 << "\nthat which the printer will do at the end of page. Though, "
                 << "\nthis may lead to words being cut in half.  This simple "
                 << "\nprogram could be made much better utilizing iomanip for text "
                 << "\nformatting, but it shows you the basics of opening a printer "
                 << "\nport. " << endl << endl
                 << "Press a '#' and return when you are ready to print... " << endl
                 << endl << endl;
            while (character != '#')
                    if(character != '#')
            prnt << '\r' << '\f' ; // return and eject the last page from the printer

  5. #5

    Post no

    It didn't print.
    Give me a bad reputation!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why i can get the result print to the screen
    By wise_ron in forum C Programming
    Replies: 7
    Last Post: 05-22-2006, 08:06 PM
  2. i am not able to figure ot the starting point of this
    By youngashish in forum C++ Programming
    Replies: 7
    Last Post: 10-07-2004, 02:41 AM
  3. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  4. What kind of programs should I start writing?
    By Macabre in forum C++ Programming
    Replies: 23
    Last Post: 04-12-2003, 08:13 PM
  5. Print Screen
    By /\/\ E /\/ @ in forum A Brief History of
    Replies: 6
    Last Post: 08-11-2002, 05:37 PM