Results 1 to 5 of 5

Thread: Printer as outputstream

  1. #1

    Thread Starter
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking Printer as outputstream

    Hello!
    Just wondering if possible to use the printer as an outputstream (ostream) similar to files and cout.

    So you can do stuff like:
    Printer<<"Printing text, and the number "<<5<<endl;

    (Then i guess something like Printer.close())

    I have converted from VBasic ages ago, and was used to treating the printer as a file or textbox.

    Also, if you can't do this, how do you access the printer?

    Thanks
    sql_lall

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    If memory serves, you can do something like this...
    Code:
    #include <fstream>
    
    using namespace std;
    
    int main()
    {
    	ofstream OUT;
    
    	OUT.open("LPT1");
    
    	OUT << "Printing Text" << endl;
    	
    	OUT.close();
    
    
    	return 0;
    }
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    That works fine for most Windows variants (dead easy to map LPT1: to a network drive, too).

    Under Unix, you can probably get away with writing to a file then just throwing it through lpr.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Or opening the printer's device file from /dev.

    Might be parn or parportn (with n being the LPT number starting with 0, par0, par1 etc.).

    lpn also sounds promising.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Thumbs up :D

    Thanks, I'll try them and get back if there are any problems
    sql_lall

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width