Thread: Help with printing

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    5

    Help with printing

    Hi,
    You see i have problem wit using the printer in c++. What i want to do, is print a text file to a printer using c++. I know that i have to use the system() function, as so "system("print <file>");
    but i have a problem..
    Im using a network printer, what exactly do i have to type after "print". People are telling me to type server name and printer location, but i have no idea how to do that or where to get the information from. Some one please tell me how do this and where to get the info from. Thanks

  2. #2
    Registered User xxxrugby's Avatar
    Join Date
    Jan 2005
    Posts
    178
    Have you try type in MS DOS -> help print
    All commands with System are console commands!
    So all you can do with System() look into ms dos and type help and you will get all what you can do!
    Then you will get something like this
    Code:
    c:\>help print
    prints a text file.
    
    PRINT [/D:device] [[drice:][path]filename[...]]
    
             /D: device     Specifies a print device
    Sorry for spelling errors, not English!
    xxxrugby: "All Human Race Will Die From My Hand!"
    xxxrugby: "We are all philosophers, when question is about politics!"

  3. #3
    Handy Andy andyhunter's Avatar
    Join Date
    Dec 2004
    Posts
    540
    OK, I am kindof hijacking this guys thread. I am not as familiar with C++ as with C but can you not just reassign streams as with C to force output to go to the printer vice console, or just simply associate cout with the printer? I found an overloaded cout on msdn but it was overly complex for basic printer ops.

    Say I want to print a txt file in C++. Can I not simply send the output to the printer stream and not worry about all the low level printer stuff? (I'm talking basics here) I know this can be accomplished in C a number of ways.

    PS - sorry to hijack your thread but you may also gain some knowledge from this.
    [edit]

    Alright, let me rephrase this. How do you do this:
    Code:
    int main(void){
    
         FILE* stream;
    
         stream = fopen("PRN", "w");
         fprintf(stream, "This goes to the printer\n");
    
         fclose(stream);
         return 0;
    }
    in C++?

    [/edit]
    -Andy
    Last edited by andyhunter; 02-10-2005 at 07:41 PM.
    i don't think most standard compilers support programmers with more than 4 red boxes - Misplaced

    It is my sacred duity to stand in the path of the flood of ignorance and blatant stupidity... - quzah

    Such pointless tricks ceased to be interesting or useful when we came down from the trees and started using higher level languages. - Salem

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C# Printing Problem
    By silverlight001 in forum C# Programming
    Replies: 0
    Last Post: 03-23-2009, 01:13 AM
  2. generic printing preferences dialog box
    By stanlvw in forum Windows Programming
    Replies: 8
    Last Post: 06-27-2008, 02:20 AM
  3. printing data to a file
    By coralreef in forum C Programming
    Replies: 3
    Last Post: 11-02-2006, 08:10 PM
  4. need help relating printing?
    By omarlodhi in forum Linux Programming
    Replies: 0
    Last Post: 03-03-2006, 04:46 AM
  5. Printing
    By Dual-Catfish in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 05-25-2002, 08:10 PM