TurboC 컴파일러를 사용하는 경우 getch();
#include<stdio.h>
#include<conio.h>
int main()
{
//your code
getch();
return 0;
}
또는 컴파일러는 GCC입니다 - 당신은() 자신의 getch을 구현하기 위해 다음과 같은 코드를 사용할 수 있습니다; 여기
단지, 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.
이며, conio.h와 및 필요 포함 없습니다 여기에 야생 짐작, 당신은 [Windows에서 Visual Studio IDE에서 실행] (https://stackoverflow.com/questions/13505173/visual-studio-20)입니까? 10- 프로그램 종료 - 실행 직후)? – WhozCraig
오, 내 실수, 내 질문은, 내가 내 합계를주기 전에 내가 원하는 번호를 입력 한 후 종결을 멈추게하려면 어떻게해야합니까? 그리고 Im은 Visual Studio 커뮤니티의 최신 버전을 사용하고 있습니다. –
그럴 경우 도움이 될 가능성이있는 [** 이전 댓글 ** 링크] (https://stackoverflow.com/questions/13505173/visual-studio-2010-program-closes-immediately-after-running) 경우. – WhozCraig