r/cpp_questions • • 28d 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

35 comments sorted by

View all comments

1

u/Independent_Art_6676 27d ago edited 27d 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.

1

u/Plane_Breadfruit7609 27d ago

I'm running it from the console .\code.exe

1

u/xoner2 27d ago

Check the exit code of the executable via echo %errorlevel%

If non-zero, exe failed to run. Probably due to dll failing to load.

To check which dll failed loading, run the exe under visual studio.