what is the terminal command to run a c++ program and to output whatever is being printed to a .txt file.

Am using in a virtual machine with VMware

@louiscouture correction this works:

g++ source.cpp && ./a.out > output.txt

I.e you compile and execute the program but redirect output to the text file.

@louiscouture just run the binary like you would run any other executable and redirect output to a file.
e.g., ./a.out > b.txt

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.