Saturday, April 20, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 5710  / 3 Years ago, sat, may 15, 2021, 3:39:08

I'm new in programming. I run simple C++ program, like this:



#include <iostream>
int main(int argc, char *argv[]) {
std::cout<<"What?";}


by using the terminal by typing g++ Program.cpp.



No error is returned after compiling, but the standard output is not shown on the line, which I think it sohould return What? as typed after std::cout<<.



What can be the cause why the standard output is not shown in terminal?


More From » command-line

 Answers
5

Well the g++ command compiles the program. You also have to link and build the program.



Try gcc -o program Program.cpp



After that you'll have to run it:



./program


Also, you forgot using namespace std;


[#25483] Saturday, May 15, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
njuash

Total Points: 402
Total Questions: 125
Total Answers: 98

Location: Jersey
Member since Sun, Dec 4, 2022
1 Year ago
;