TurboCコンパイラを使用している場合は、getch();を使用します。
#include<stdio.h>
#include<conio.h>
int main()
{
//your code
getch();
return 0;
}
またはコンパイラGCCです - あなたは(自分のgetchはを実装するには、次のコードを使用することができます)。そして、ここでconio.h
を含める必要はGCC
#include <termios.h>
#include <stdio.h>
static struct termios old, new;
/* Initialize new terminal i/o settings */
void initTermios(int echo)
{
tcgetattr(0, &old); //grab old terminal i/o settings
new = old; //make new settings same as old settings
new.c_lflag &= ~ICANON; //disable buffered i/o
new.c_lflag &= echo ? ECHO : ~ECHO; //set echo mode
tcsetattr(0, TCSANOW, &new); //apply terminal io settings
}
/* Restore old terminal i/o settings */
void resetTermios(void)
{
tcsetattr(0, TCSANOW, &old);
}
/* Read 1 character - echo defines echo mode */
char getch_(int echo)
{
char ch;
initTermios(echo);
ch = getchar();
resetTermios();
return ch;
}
/*
Read 1 character without echo
getch() function definition.
*/
char getch(void)
{
return getch_(0);
}
int main(){/*your statements*/ getch(); return 0}
のコードではありません参考 gotoxy(), clrscr(), getch() and getche() functions for GCC Linux.
あなただけ、質問をするのを忘れて、ここで野生の推測、あなたは[これは、Visual Studio IDEからWindows上で実行している](https://stackoverflow.com/questions/13505173/visual-studio-20 10-プログラムクローズ - 実行直後)? – WhozCraig
ああ、私の間違い、私の質問は何ですか、私はそれが私の合計を与える前に私が欲しい番号を入力した後にそれを閉じることができます。と私はビジュアルスタジオコミュニティの最新バージョンを使用しています。 –
もしあなたがそうであれば、私の以前のコメントの**リンク**(https://stackoverflow.com/questions/13505173/visual-studio-2010-program-closes-immediately-after-running)が役に立つでしょう。ケース。 – WhozCraig