C/C++ Printing from Visual C++ output

AI Thread Summary
To print the output from a C++ program running in a DOS environment, redirect the output to a text file using the command "myprogram.exe > result.txt" and then print the file using "print result.txt" or by double-clicking the file and selecting print. An alternative method mentioned is redirecting output directly to a printer using "myprogram.exe > prn" or "myprogram.exe > lpt1", although compatibility may vary, especially in DOSBox. For networked printing, users can share a printer and connect it to LPT1 using the command "net use lpt1: \\mymachine\myprinter", allowing direct printing even from USB-connected printers.
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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Back
Top