When i start after building the program won't run

Any program I attempt to run without debugging, will run, the window pops up, and then closes itself immediately. Can anyone tell me why this happens? Or at least how I can remedy this problem?
Mind you I am using microsoft visual studio 2010
Well it would help if you posted the source code (Use code tags!) but i think that its because it has nothing to pause it so it just runs then immediately closes
let's say i am trying to run a simple program such as this,

#include <stdio.h>
int main(void)
{
int i;

i=1;
while(i<=128){
printf("%d ", i);
i*=2;
}

return 0;
}

the output of course would be,
2,4,8,16,32,64,128

Am i forgetting to put something in the code?
http://cplusplus.com/forum/beginner/1988/

Programs that use cout, cin, ... are meant to be run from a terminal. When you run them from outside of one, a terminal is created for the program and discarded when it's finished.

A Solution: write a batch/shell file that looks something like this:
@my_program.exe arg1 arg2 ...
@pause
Then run that instead.
Last edited on
Topic archived. No new replies allowed.