make the printer function on my program!!!!

This is a discussion on make the printer function on my program!!!! within the C++ Programming forums, part of the General Programming Boards category; hello all~~~ i have question that can i print out my console window by using printer directly by enter some ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    15

    make the printer function on my program!!!!

    hello all~~~
    i have question that can i print out my console window by using printer directly by enter some character in my program ???

    example
    do you wan to print this console window? p

    after user enter p, the printer start printing the particular console window.

    i am using
    compiler:MinGw
    OS:windowXp

    the program should run under console window app mode....

    thanks~~~

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,062
    I'm really not understanding what you're asking...

    ...if you're talking about an actual print (that prints ink on a sheet of paper), then the simplest way would be to just open the printer port as a file and output to it like you would a text file.

    Code:
    #include <fstream>
    
    int main() {
      std::ofstream Printer;
      Printer.open("LPT1");   // This may not nessasarily be your printer port.
    
      Printer << "PRINTED TEXT. \f";  // The \f is formfeed.
      Printer.close();
    
      return 0;
    }
    Also, you should understand that this has a ton of flaws. It only works assuming your printer can recieve plain text. For example, a PostScript printer won't print unless the output is coming through a PostScript printer driver. If you want to do it correctly, then look into some documentation on Windows XP and find out how to send the output to the OS's printer manager.
    Last edited by SlyMaelstrom; 03-17-2006 at 03:18 AM.
    Sent from my iPadŽ

  3. #3
    Registered User
    Join Date
    Sep 2005
    Posts
    15
    ya......wat i mean is print it on a paper....
    means when the user keep in some command the printer will start to print out the console window excute by the user on that time...

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    Some enviroments have a C file stream called stdprn.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. Bisection Method function value at root incorrect
    By mr_glass in forum C Programming
    Replies: 3
    Last Post: 11-10-2005, 08:10 AM
  4. Change this program so it uses function??
    By stormfront in forum C Programming
    Replies: 8
    Last Post: 11-01-2005, 07:55 AM
  5. Replies: 3
    Last Post: 03-04-2005, 01:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21