well...I'm trying to link my Visual Studio 2008 to printer and print text by using the printer...but I'm failed to do so...can anyone please help me to rectify my error?
What runtime error? What line of code? Why do you think the ofstream object named 'print' is linked to the printer? ofstream stands for "output file stream", meaning is good for writing files, not to print on printers.
In order to print something on a page, you draw with GDI/GDI+ using the printer's device context. Try TextOut() for instance.
but I'm going to merge this printing code with my another code....and it consist lots of input from user....if i use TextOut() then where should i place my output at? in order to print it out? like the name on line 36....I prompt the user to enter their name and choice to print...and the output should be their name....
Since we are talking printers here, and since the term print is also applicable to the screen, please use "print to screen" or "print to printer" to make things 100% clear. Just to make sure we are talking the same.
If you do TextOut(hPrinter, 100, 100, name.c_str(), -1);, then you'll get the name the user input in a printed page. Does this make it better?