Run C++ program from terminal. Get output in same terminal window
10,696
I believe gcc comes with the XCode tools package.
If you have gcc installed, open terminal window, cd to the directory where you put your cpp file, and type:
g++ myTestFile.cpp -o main; ./main
Replace 'myTestFile' by the name of your file, naturally. you can also rename the 'main' which is just the name of the compiled module, which you need to run by typing ./main to retrieve the output of your code.
Author by
user1361521
Updated on June 05, 2022Comments
-
user1361521 almost 2 years
When I run my c++ programs from Terminal (Mac OS X), output from programs is shown in a new Terminal window.
What can I do to prevent the new window, and just have the programs' output straight in the window thats already open?