-2

I have compiled the program but unable to see the results after compiling it because the console screen flashes out in sec.

#include "stdafx.h"
#include <stdlib.h>

int main(int argc, char* argv[])
{
printf("Hello World!\n");
system("pause");
return 0;
}
Bilal
  • 265
  • 8
  • 20
  • 1
    what does "the console screen flashes out in sec." mean? your program should pause at the end. Furthermore, try running your program from the command line. Also, I'd highly recommend using a more recent compiler... – codeling Dec 20 '13 at 13:45
  • 1
    Also it seems that [`system("pause");`](http://stackoverflow.com/q/1107705/332733) is not recommended – Mgetz Dec 20 '13 at 13:48
  • Visual C++ 6.0? _Why_? – Lightness Races in Orbit Dec 20 '13 at 14:05
  • 1
    weird. Compiled it with VS2012 on Seven. No flash but waiting I hit a key. try to catch the system call return value with int iRetVal=system("pause"); – manuell Dec 20 '13 at 14:20

1 Answers1

1

You could write some code to read a char from the console window. That way the console application won't exit before you have written a char to it.

Check this answer: How to stop C++ console application from exiting immediately?

Community
  • 1
  • 1
andreasnico
  • 1,478
  • 14
  • 23