Printing from Visual C++ output

In summary, To print the output from a c++ program displayed on a DOS screen, you can use the command myprogram.exe > result.txt to redirect the output to a text file. Then, you can either print the text file or double click on it and select print. Alternatively, you can share your system printer using network shares and connect lpt1 to that printer to print directly from the program. However, this method may not work for all printers.
  • #1
Freyster98
49
0
I need to be able to print the output from my c++ program, which obviously comes up in a dos screen. Is there an easy way to print this without writing it into the code? Any help would be greatly appreciated.
 
Technology news on Phys.org
  • #2
myprogram.exe > result.txt
print result.txt or double click on result.txt and select print
 
  • #3
mgb_phys said:
myprogram.exe > result.txt
print result.txt or double click on result.txt and select print

excellent, thanks!
 
  • #4
IIRC in good ole times it was something like myprogram.exe > prn or myprogram.exe > lpt1. No idea if it works in dosbox.
 
  • #5
Not directly (at least for most simple laser printers)
You can share the regular system printer using network shares and then connect lpt1 to that printer.
eg.
net use lpt1: \\mymachine\myprinter

You can then print directly to lpt1: even if it is a gdi/winlaser on a usb port.
 

What is printing from Visual C++ output?

Printing from Visual C++ output refers to the process of sending information or data from a Visual C++ program to a physical printer device, resulting in a printed document or image.

How can I print from Visual C++?

To print from Visual C++, you need to use the PrintDocument class from the .NET Framework. This class provides methods and properties for controlling the printing process, such as setting the printer, page size, and content to be printed.

Can I customize the print output?

Yes, you can customize the print output in Visual C++ by using the PrintDocument class's event handlers. These event handlers allow you to specify the content and layout of the printed document, such as adding headers and footers, changing font styles, and inserting images.

How do I handle errors during printing?

In Visual C++, you can handle errors during printing by using the PrintDocument class's PrintPage event. This event is triggered when a print page is being generated, and you can use it to check for any errors and handle them accordingly.

Can I preview the print output before sending it to the printer?

Yes, you can preview the print output in Visual C++ by using the PrintPreviewDialog class from the .NET Framework. This class allows you to display a print preview window where you can see how the final print output will look like before sending it to the printer.

Similar threads

  • Programming and Computer Science
Replies
29
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
2
Views
764
  • Programming and Computer Science
Replies
25
Views
2K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
2
Replies
43
Views
2K
  • Programming and Computer Science
Replies
4
Views
320
  • Programming and Computer Science
Replies
3
Views
2K
  • Programming and Computer Science
Replies
2
Views
755
Back
Top