관리 메뉴

드럼치는 프로그래머

[C] getchar(), getche(), getch 본문

★─Programing/☆─C | C++

[C] getchar(), getche(), getch

드럼치는한동이 2007. 7. 12. 04:50

//getchar(), getche(), getch ---문자 입력 함수

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

int main()
{
 char ch;


 //getchar() --Enter키를 만나야 버퍼의 문자를 읽기 시작한다.
 printf("문자를 계속 입력하고 Enter를 누르면 >>\n");
 while((ch=getchar()) != 'q')
  putchar(ch);


 //putchar() --버퍼를 이용하지 않고 문자 하나 하나를 바로 처리하는 함수
 //헤더파일 conio.h 파일 첨가해야한다.
 printf("\n문자를 누를 때마다 두 번 출력>>\n");
 while((ch=getche()) != 'q')
  putchar(ch);


 //putch() --버퍼 사용 하지 않고, 입력한 문자 출력 안됨,
 printf("\n문자를 누르면 한 번 출력>>\n");
 while((ch=getch()) != 'q')
  putchar(ch);


 printf("\n");

 return 0;
}

'★─Programing > ☆─C | C++' 카테고리의 다른 글

[C] 문자열 비교를 위한 strcmp  (0) 2007.07.12
[C] 아스키 코드 표  (0) 2007.07.12
[C] 연결리스트 ( Link List ) _Win  (0) 2007.07.11
[C] Quick_Sort 퀵정렬  (0) 2007.07.11
[C] M2S Study 과제 <포인터>부분  (0) 2007.07.10
Comments