Search code examples
c++consoletermination

How to close the console window after the program?


I'm trying to make a program which will close the console window after execution. But it outputs this instead:

(the program output)
--------------------------------
Process exited after 15.7973 seconds with return value 0
Press any key to continue . . .

I don't want to see this message, I just want to make the program which will completely close the window.

End of my program:

   ...
   if(getch==116){
     ...
   }
   system("pause >nul");
   return 0;
}

I'm using Dev-C++.


Solution

  • The console window is normally closed when you run your exe with a double-click outside of IDE, or when run in debug mode with F5. Avoid the use of system("pause") or system("pause > NULL"). Avoiding "Press any key to continue" when running console application from Visual Studio