1

たとえば、単純なスイッチケースを作成した場合、入力に応じてコンソール アプリを閉じるにはどうすればよいでしょうか? ブレークを使用したくありません。ループをスキップして、コンソールを完全に閉じたいと思います。

char choice; 

printf("Run random function \n");
printf("Exit \n");

choice = getchar();
fflush(stdin);

switch(choice)
{

            case '1':
                 //randomFunction();

            case '2':
                 //I want this case to exit the console the console
}
4

2 に答える 2

1

単に使用するexit (EXIT_SUCCESS);

参照 -終了

于 2013-08-31T16:16:27.083 に答える
0

戻り値をパラメーターとして渡して呼び出すことができexit()ます。この戻り値は、呼び出し元のプロセス/バッチ ファイルで確認できます。

exit(EXIT_SUCCESS); // = 0 = (standard) success

また

exit(EXIT_FAILURE); // = 1 = (standard) failure

また

exit(123); // return a specific value

MS-Visual Studio のドキュメント

于 2013-08-31T16:15:30.967 に答える