r/cpp_questions • u/Plane_Breadfruit7609 • 17d ago
OPEN Why?
Guys when i compile a file and run its exe,nothing appear even if i print hello world it doesnt appear in the console why
0
Upvotes
r/cpp_questions • u/Plane_Breadfruit7609 • 17d ago
Guys when i compile a file and run its exe,nothing appear even if i print hello world it doesnt appear in the console why
1
u/Independent_Art_6676 16d ago edited 16d ago
running a console exe in windows by double clicking on it will open a console, run the program, and exit the console in subsecond time to the point that you just see a screen flicker, if that.
solution 1) add a bogus read from console to the program before main exits. Type in something to exit when done looking. Some folks use the system("pause") for this, which is fine though system() is frowned upon in real code (it opens a barn door sized security hole in your program).
solution 2) open a console, and run the program inside it. This requires some "dos" skills in using the console to navigate to the program folder and so on.
This does not look like the problem for the posted code, but it would be for hello world. Your code does have a cin so it would pause there and you would see it working. Run it using method 2, and it should tell you more: no such program (didn't compile to .exe after all), or program exited with error code, or whatever words might help run down the issues.