Help with c++ program

jimithing2077

Member
Mar 22, 2004
138
0
0
Hey guys, I'm very new to the whole c++ programming and I just started my intro course at MSU. I ran across the following problem...

Everytime I run my program inside of VS, it runs perfect. But then when I go and actually find the .exe file that is created after you build and compile the .cpp file, it runs the first line but then when it gets to a question where you have to input something and hit enter, it automatically exits the command window.

Does anyone know why it keeps doing this?! Thanks a lot

 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Make sure that you flush your input buffers before the input request.

Also check via a diagnostic what was inputed and how many charcters.
 

Titan

Golden Member
Oct 15, 1999
1,819
0
0
code would help.

I know some console apps are paused when run from VS, but don't pause when you run outside, they just run and exit. If you see "press any key to continue" in your console, that is put there by VS. If you see "Press any key to continue..." (note the ...) That means you put a call to system("PAUSE"); before the end of your code. This will solve this problem.

Not sure exactly what you're describing, can you be more specific?
 

Jeraden

Platinum Member
Oct 9, 1999
2,518
1
76
Are you running it by double-clicking on the .exe in windows, or going to a command prompt and typing it in? If its a console application, you'd need to open a command prompt and type the .exe name in.
 

Bulldog13

Golden Member
Jul 18, 2002
1,655
1
81
run the code from a prompt

"start" - "run" - "cmd"

then navigate to where the directory is and run the file