메뉴 건너뛰기

창조도시 기록보관소

언어 [수정]C언어에서... 답변.

2005.05.25 21:38

비밀소년 조회 수:10 추천:1

>scanf() 함수를 사용하지 않고...
>
>프로그램이 실행하는 도중에 잠시 대기했다가, Enter키를 누르면 계속 프로그램이 실행되는 것은
>
>어떻게 만들 수 있나요?
>
>방법이 있기는 한 건가요?


#include -> #include <stdio.h>
#include -> #include <conio.h>
char ch;
void enter(void)
{
printf("☞");
do{
getch(); -> ch = getch();
}while(ch !=SPACE || ch !=ENTER); -> ch !=SPACE && ch !=ENTER
printf("%n"); -> printf("\n");
}

int main() -> void main() //리턴 1 이 없을 경우 void로 해주어야 워닝이 안뜹니다
{
printf("안녕하세요. 접니다. 쿨럭."); enter();
printf("자, 그럼 보러갈까요?"); enter();
}


-------------------------------------------


#include <stdio.h>
#include <conio.h>

// 함수들의 선언
bool is_space_or_enter(ch);
void enter();

// 메인은 위쪽에 놓아야 읽기 편합니다.
void main()
{
   printf("안녕하세요. 접니다. 쿨럭."); enter();
   printf("자, 그럼 보러갈까요?"); enter();
}

// 13 = Return, 32 = Space
bool is_space_or_enter(ch)
{
   if(ch == 13 or ch == 32)
      return true;
   else
      return false;
}

// 포즈
void enter()
{
   char ch;
   printf("☞");
   while(is_space_or_enter(getch()) != true);
   printf("\n");
}