0

i would like to point out i'm a bit new to programming and to using VS. my problem is, whenever I write a C program and press Ctrl + F5 it flashes the window for 1 second then it goes away. When i add SYSTEM("PAUSE") at the end it starts to work but I don't want to have to do that every time and in and out of my source code. Is there any other solution?

Nikita R.
  • 7,245
  • 3
  • 51
  • 62
Atalia.d
  • 131
  • 1
  • 13
  • Not exactly sure what you are after. But how about opening cmd.exe and pointing it to your Release directory and running it out of the command prompt? – Lucas Oct 01 '15 at 20:50
  • 1
    One thing you can do is to run your application not from the VS, but from the external command line. Open the cmd, navigate to the location of the binary you need to execute and run it explicitely. Not ideal, because you need to build in the VS, switch windows and re-run each time, but that's the only thing I can think of right now. – Nikita R. Oct 01 '15 at 20:50
  • 2
    You might need to set the subsystem to console (Project Properties>Configuration Properties>Linker>System>SubSystem) See [this](http://stackoverflow.com/q/1775865/33499) and [this](http://stackoverflow.com/q/454681/33499) – wimh Oct 01 '15 at 21:03
  • Put a getch() before the exit/return statement. This will force the system to wait until you hit a character. If you are running on Linux, getch is buffered so hit return to exit. Note that this will only work if you do not have multiple exits in your program. – cup Oct 01 '15 at 22:42
  • As commented, you could run from the regular dos console window, or you could click on start / all programs / ... visual studio ... / ... tools / visual studio ... command prompt. This sets up the environment so you can use the command line to compile and link as well as run your program. – rcgldr Oct 02 '15 at 01:19
  • setting the subsystem worked, but it seems like i can't make it a default setting. getch() works as well, same as 'system("pause")' but still, i would have to add it in every single project. isn't there a way to make it run without adding lines or changing the settings in every project? because i know it's possible to make it run without debugging just using ctrl+f5, it does work for my classmates from some reason. – Atalia.d Oct 03 '15 at 15:20

1 Answers1

0

Project-> Properties-> Linker-> System-> Subsystem. Now in the Subsystem line enter: Console (/SUBSYSTEM:CONSOLE) Press Ok.