Thanks you for posting your log! Thwe answer is right there.
-mwindows
This indicates that you have told the compiler to compile Windows
(GUI) code, but the code you are working with is console code. This will cause
a console program to fail to output results.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I am a new user to C++. My simple Hello world program does not output anything
in the command window:
// my first program in C++
include <iostream></iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
system("Pause");
return 0;
}
Compile Log:
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Progs\first.cpp" -o "C:\Progs\first.exe" -pg -g3 -mwindows -I"C
:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-
Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C
:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -lgmon
-pg -g3 -mwindows
Execution terminated
Compilation successful
Can you advise me on why there is no Hello World! output in the command window
please?
The directive #include is for the iostream file but this does not paste
properly on the forum.
Thanks you for posting your log! Thwe answer is right there.
-mwindows
This indicates that you have told the compiler to compile Windows
(GUI) code, but the code you are working with is console code. This will cause
a console program to fail to output results.
Wayne
Sigh.
Note:
This is what you could have have had:
// my first program in C++
include <iostream></iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
system("Pause");
return 0;
}
Build log:
Compile Log:
Compiler: Default compiler
Executing g++.exe... g++.exe "C:\Progs\first.cpp" -o "C:\Progs\first.exe" -pg
-g3 -mwindows
-I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C
:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C
:\Dev-Cpp\include
" -L"C:\Dev-Cpp\lib" -lgmon -pg -g3 -mwindows
Execution terminated
Compilation successful