getch 와 _getch

from Study/C언어 2007/03/14 09:12 view 25631

ANSI C에서 정의한 함수가 getch이고 VC++ 컴파일러 에서 지원하는 함수가 _getch이다.

굳이 표준 외에 함수를 만든 이유가 무엇일까 생각해봤는데

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

void main( void )
{

   /* Display message until key is pressed. */
   while( !_kbhit() )
      _cputs( "Hit me!! " );

   /* Use _getch to throw key away. */
   printf( "\nKey struck was '%c'\n", _getch() );
   _getch();
}

만약에 이 소스에 getch라는 변수를 추가 했을때 getch()함수를 사용했다면

error C2064: term does not evaluate to a function

와 같은 에러를 볼 수 있다. 이를 방지 하기 위해서 '_'를 붙인 함수를 만든건 아닐까라는

생각이 든다. 그래서 변수명앞에 '_'를 사용하는 것을 금하는 거 아닐까-_-..

Trackback Address :: 이 글에는 트랙백을 보낼 수 없습니다