I am coming from XCode and this is probably a stupid question, but after I build my program successfully, I try to click on the Application in the debug folder and the window just closes. How do I run my application that I create?
A:
You can compile and run the program by pressing F5.
However, if you're talking about non-gui console application which just prints something and exists, the output window will close right away. If this is the case, you might want to open command prompt (cmd.exe) and run it from there manually, or insert some "wait for keypress" handling, such as getchar().
Otherwise, there might be something wrong with your program :)
joukokar
2009-11-16 07:31:33
How do I run it from cmd.exe? I went to the folder where my .exe was created, typed in my program: "Assignment.exe" and nothing happened.
jet
2009-11-16 07:37:01
Also, when I try to hit F5 in Vis Studio, this is my output: 'Assignment8_1.exe': Loaded 'C:\Documents and Settings\jon\My Documents\Visual Studio 2008\Projects\Project1\Assignment8_1\Debug\Assignment8_1.exe', Symbols loaded.'Assignment8_1.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll''Assignment8_1.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll''Assignment8_1.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcr90d.dll'The program '[2124] Assignment8_1.exe: Native' has exited with code 0 (0x0).
jet
2009-11-16 07:38:08
That's strange.But it seems to be working fine. What is your program supposed to do?
joukokar
2009-11-16 07:50:14
+2
A:
The above answers are correct, but if your question is simply why your command prompt closes immediately upon your program's termination, you have two options:
- Put a breakpoint on your main()'s } before you run.
- Use Ctrl+F5, which will add a "Press any key to continue" at the end so you can see all of your program's output, but it will launch the application without attaching the debugger.
Morbo
2009-11-16 07:41:56
Well I can see the Press any key to continue, but I don't know why there is nothing output to the screen. I copied and pasted my code that was running on XCode and you'd think I'd get the same output right?
jet
2009-11-16 07:49:20