Exit a c program via CMD

Asked

Viewed 783 times

1

In the following code, when I press 9 the program must close:

case 9:
   exit(0);

After pressing 9 the screen below in cmd is displayed, but after pressing 9 is displayed the message: Press to close this window... and it is necessary to click a key again to close the cmd window. The question is, is there any command that directly closes the cmd window when pressing number 9? inserir a descrição da imagem aqui

  • If you open directly the application...will come out... only q if you are in cmd and open the application by it, why would you close the cmd ? and put all your code so we know what the program is really doing

  • Is this C or C++? If it’s C++ is using Qtsdk to create the code? Because if it’s C++ QCoreApplication::exit(int returnCode); or next to it (changing the int returnCode by the number that will represent the output, usually 0, thus: int main(int argc, char *argv[])
{
 QCoreApplication a(argc, argv);

 /* Usando algum sinal emitiria os "eventos" e executaria a.exit() */

 return a.exec();
})

1 answer

3

case 9:
break;

So I’m out... or you can use the remote:

system("exit");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.