Can someone give me an example of how to print a string to the printer? I seem to be having problems doing this.
Printable View
Can someone give me an example of how to print a string to the printer? I seem to be having problems doing this.
I've never done it, but I think printing to a printer is the same as using the streams in C++ (Files, Console io, etc) but that you have to map it to LPT1 or something.. I try to look something up for ya!
http://www.studio-ide.com/downloads/usingvc/tips.html
http://www.catenary.com/howto/prfsheet.html (looks complicated but I guess it produces good results)
http://www.eca.com.ve/cs/C++%20Ref/fun_stuff.htm#print
enjoy ;)
Great thanks I will try the stream. I was trying to use OpenPrinter, WritePrinter, etc and was failing.
Ok neither worked. I have XP an the printer is local but the stream isn't working. Nothing happens and it locks on the close so it must not be getting opened
have you tried this
--------------
include <stdio.h>
void main()
{
FILE *printer;
printer = fopen("LPT1,"w");
fprintf(printer,"Hello World");
}
----------------
or can have it go to disk and then print it out,
remember to have disk in a:
----------------
include <stdio.h>
void main()
{
FILE *todisk;
todisk = fopen("a:\myfile.txt,"w");
fprintf(todisk,"Hello World");
}
-------------