退出C程序

Anc*_*end 2 c

我是C编程的新手.在我下面的程序中,我只是想立即尝试退出C程序,而不会看到任何其他对话框,如果程序收到输入"退出".

我试图完成这个使用,exit(0);然而,在程序退出之前输出类似的东西

success
process exited with return value 0
Press any key to continue...
Run Code Online (Sandbox Code Playgroud)

我试图避免此对话框并立即退出程序.这可能吗?

我很感激任何帮助.

提前谢谢了!

我的C代码:

#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int main(void)  {
    char command1[256], command2[256];
    printf("# ");
    scanf("%s", command1);
    if(strcmp(command1,"quit")==0){
        printf("success");
        exit(0);
    }else{
        printf("unknown command");
    }

system("PAUSE");
return 0;

}
Run Code Online (Sandbox Code Playgroud)

Mik*_*scu 6

您看到的消息实际上是由Visual Studio调试器生成的.它并非真正来自您的计划.

如果您想验证您的程序实际上没有显示任何消息(也没有等待按键),只需尝试从Windows命令提示符运行它.您也可以尝试使用Visual Studio以"发布"模式运行程序.这也将证实这一点.

调试器显示该信息的原因只是为了帮助您了解程序的运行情况.