Printing from Visual C++ output

Click For Summary

Discussion Overview

The discussion revolves around methods for printing output from a C++ program that is displayed in a command line interface (DOS screen). Participants explore various approaches to achieve this without modifying the program's code, focusing on practical solutions and historical methods.

Discussion Character

  • Technical explanation, Practical application, Historical

Main Points Raised

  • One participant inquires about an easy way to print output from a C++ program without altering the code.
  • Another participant suggests redirecting the output to a text file using the command "myprogram.exe > result.txt" and then printing that file.
  • A later reply confirms the previous suggestion and expresses gratitude for the help.
  • One participant recalls a historical method of printing directly to a printer using "myprogram.exe > prn" or "myprogram.exe > lpt1," questioning its applicability in modern environments like DOSBox.
  • Another participant notes that direct printing to most simple laser printers is not feasible, but suggests sharing a system printer over a network and connecting it to lpt1 to enable printing from the command line.

Areas of Agreement / Disagreement

Participants present multiple methods for printing output, with no consensus on the best approach. Some methods are based on historical practices, while others focus on modern solutions.

Contextual Notes

Some methods may depend on specific system configurations, such as network printer sharing and compatibility with modern operating systems. The applicability of historical methods in current environments remains uncertain.

Freyster98
Messages
49
Reaction score
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
myprogram.exe > result.txt
print result.txt or double click on result.txt and select print
 
mgb_phys said:
myprogram.exe > result.txt
print result.txt or double click on result.txt and select print

excellent, thanks!
 
IIRC in good ole times it was something like myprogram.exe > prn or myprogram.exe > lpt1. No idea if it works in dosbox.
 
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.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 25 ·
Replies
25
Views
3K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 29 ·
Replies
29
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
1
Views
2K