I'm just trying to get my c++ code to output properly in terminal on my mac, but it doesn't show anything. I'm using xcode as a text editor, saving the file as Code.cpp, and then typing g++ Code.cpp into terminal. Before it was showing errors when my code had bugs, but now that it runs correctly it doesn't show any output. Any thoughts? Here's my code:
#include <iostream>
using namespace std;
int main() {
cout << "Hello World" << endl;
return 0;
}
Here's what I put into terminal, and it just skips down to the next line without the "Hello World" output.
jspencer$ g++ Code.cpp
jspencer$
Thanks in advance for the help!!
a.out
, so run it as./a.out
. If you want to compile with some other name, use the-o
option, such asg++ code.cpp -o myexecutable
. Also, can I grab you while you are just getting started, and warn you about the evils ofusing namespace std;
. – Subscriptendl
(also a link) either, but people have mixed feelings about that one. – Subscriptusing namespace std;
. – Subscriptc++
, just teaching the same thing once a year and never un-learning their own bad habits. – Subscript