logo

C의 Conio.h

우리는 이 에세이에서 C에서 매우 유용한 conio.h 헤더 파일에 대해 배울 것입니다. 또한 conio.h에 포함된 기능과 C 프로그래밍 언어에서 conio.h의 사용법을 살펴보겠습니다.

자바 역방향 문자열

C 프로그래밍에서 conio.h는 무엇입니까?

C 프로그래밍 언어에서 사용되는 가장 일반적인 유형의 헤더 파일입니다. 콘솔 입출력의 경우 약어입니다. C 프로그램은 입력 및 출력을 위해 conio.h에 내장된 라이브러리 함수를 많이 사용합니다. 하나의 컴파일러에서 다음 컴파일러로 conio.h 파일 내에서 다른 함수가 정의될 ​​수 있습니다.

C에서 conio.h를 사용하는 이유는 무엇입니까?

Conio.h는 콘솔에서 입출력을 실행하거나 사용자의 키보드에서 입력을 받아 화면에 결과를 표시하는 데 일반적으로 사용되는 여러 내장 함수가 포함된 헤더 파일입니다. getch()와 같은 여러 conio.h 루틴은 사용자가 키를 누를 때까지 화면을 유지하는 데 사용됩니다.

C 파일 conio.h에 선언된 함수

conio.h 헤더 파일에는 다양한 기능이 포함되어 있으며 그 중 일부는 다음과 같습니다.

    clrscr()

이 기능을 사용하면 화면의 출력을 지울 수 있습니다.

암호:

 #include #include int main() { printf('Welcome to JavaTpoint'); printf('
This is the Second sentence of the program'); clrscr(); printf('Output After using clrscr() function'); return 0; } 

산출

 Output After using clrscr() function ????????????????????.. Process executed in 1.11 seconds Press any key to continue 

설명:

여기 위의 코드에서는 두 개의 명령문을 인쇄하기 전에 clrscr() 함수를 활용했으며 두 개의 헤더 파일 stdio.h 및 conio.h를 포함했습니다. 따라서 clrscr() 메서드 위의 모든 문이 지워집니다.

    getch()

키보드는 한 문자를 읽습니다. 문자 반향을 방지합니다. 애플리케이션을 계속 진행하거나 닫기 전에 사용자가 아무 것도 입력할 때까지 창은 열려 있어야 합니다.

암호:

 #include #include int main() { printf('Enter your character: '); getch(); return 0; } 

산출

 Enter your character: Press any key to continue ???????????????????????????? Process executed in 1.22 seconds 

설명:

위 코드에는 두 개의 헤더 파일 stdio.h 및 conio.h가 포함되어 있으며 키보드에서 입력을 요청하기 위해 한 줄을 인쇄한 후 사용자가 데이터 입력을 중지할 때까지 기다리는 getch() 메서드를 활용했습니다.

    겟체()

영숫자 값도 지원한다는 점을 제외하면 getch()와 다소 유사합니다. 입력으로 제공되는 문자를 동시에 게시하고 해당 문자를 화면에 에코합니다.

암호:

 #include #include int main() { printf('Enter your character: '); getche(); return 0; } 

산출

 Enter your character: j Press any key to continue. ???????????????????????????? Process executed in 1.22 seconds 

설명:

따라서 위 코드에서는 헤더 파일 stdio.h 및 conio.h를 포함하고 사용자 입력을 표시하는 한 줄을 작성한 다음 getche() 함수를 사용하여 영숫자 문자를 가져와 화면에 인쇄했습니다. 동시에 콘솔.

    퍼치()

콘솔이나 화면에 문자를 인쇄하거나 표시합니다.

암호:

 #include #include int main() { char str = 'j'; putch(str); return 0; } 

산출

 j Press any key to continue. ???????????????????????????? Process executed in 1.22 seconds 

설명:

두 개의 헤더 파일 stdio.h 및 conio.h를 사용하여 먼저 문자열 변수에 문자를 배치했습니다. 그런 다음 putch()를 사용하고 여기에 변수를 전달하면 화면에 문자가 인쇄됩니다. 이는 getch() 메소드에서 수행된 것과 동일한 작업입니다.

    cgets()

캐리지 리턴(CR) 및 줄 바꿈(LF)이 수신될 때까지 콘솔의 입력으로 문자열을 허용합니다. 새로운 선 효과(n)는 두 가지를 결합한 결과입니다. 따라서 문자열 끝에 있는 널 종결자(O)는 이러한 CR/LF 문자를 대체하는 데 사용됩니다.

암호:

 #include #include int main() { char s[100]; char *str; s[0] = 50; printf('Input the character:'); str = cgets(s); printf('
Output on the screen: %s', str); return 0; } 

산출

 Input the character: Welcome to JavaTpoint Output on the screen: Welcome to JavaTpoint ???????????????????????????. Press any key to continue. Process executed in 0.11 seconds 

설명

부분 파생 라텍스

여기 위의 코드에서는 stdio.h와 conio.h라는 두 개의 헤더 파일을 포함시킨 다음 크기가 100인 변수 s와 입력 값을 저장하고 인쇄하는 데 사용하는 str 변수를 만들었습니다. 그 후, 문자열을 입력하기 위해 cgets()를 사용하고 여기에 변수 s를 저장한 다음 마지막 명령문에서 값을 인쇄합니다.

    CPUTS()

출력 화면이나 터미널에 모든 문자열을 표시합니다.

암호:

 #include #include int main() { cputs('Welcome to JavaTpoint'); return 0; } 

산출

 Welcome to JavaTpoint. ???????????????????????????. Press any key to continue. Process executed in 0.11 seconds 

설명:

위 코드에는 stdio.h와 conio.h라는 두 개의 헤더 파일이 포함되어 있으며, CPUts를 사용하여 문자열을 콘솔에 표시하는 문자열을 인쇄했습니다.

    cscanf() 및 cprintf()

둘 다 scanf() 및 printf()와 유사하게 작동합니다. Scanf()는 콘솔에서 사용자가 제공한 입력을 준비하고 printf()는 형식이 지정된 문자열을 콘솔이나 화면에 인쇄하기 전에 문자열에 대해 동일한 작업을 수행합니다.

 #include #include int main() { char marks[50]; cprintf('Enter your marks: '); cscanf('%s', marks); cprintf('
Passed, %s',marks); return 0; } 

산출

 Enter your marks: 80 Passed, 80 ??????????????? Press any key to continue Process executed in 1.11 seconds 

설명

여기 위 코드에는 stdio.h와 conio.h라는 두 개의 헤더 파일이 포함되어 있습니다. 그런 다음 mark라는 문자열 데이터 유형의 변수를 사용하고 크기는 50입니다. 다음으로 cprintf() 함수를 사용하여 한 줄을 인쇄하고 cscanf() 함수를 사용하여 사용자 입력을 수집했습니다. cprintf() 함수를 다시 한 번 사용하여 콘솔에 문자열을 인쇄합니다.

    kbhit()

이 기능을 사용하면 사용자가 키를 눌렀는지 여부를 확인할 수 있습니다. 플레이어가 키를 눌렀는지 여부를 확인하기 위해 수많은 게임에서 활용됩니다.

암호:

 #include #include int main() { do{ printf('To stop this loop press any key
'); }while(!kbhit()); return 0; } 

산출

 To stop this loop press any key To stop this loop press any key To stop this loop press any key ... Until the key is pressed ?????????????????? Press any key to continue Process executed in 1.11 seconds 

설명:

kbhit() 메서드는 stdio.h와 conio.h라는 두 개의 헤더 파일이 포함된 후 위 코드의 while 루프에서 사용되었습니다. 따라서 kbhit() 메소드는 키를 누르기 전까지 루프를 계속하며, 키를 누르지 않으면 키가 중지되고 프로그램이 종료됩니다.

    델라인()

이 기능은 화면에서 한 줄 또는 여러 줄을 삭제하는 데 사용됩니다.

암호:

 #include #include int main() { printf('Welcome to JavaTpoint'); printf('
 Due to the delline function being used below, this line will be cleared.'); delline(); printf('
Text printed after using delline function.'); return 0; } 

산출

 Welcome to JavaTpoint Due to the delline function being used below, this line will be cleared. Text printed after using delline function. ??????????????????????????. Press any key to continue Process executed in 1.11 seconds 

설명:

여기 위 코드에는 stdio.h와 conio.h라는 두 개의 헤더 파일이 포함되어 있습니다. 그 후 두 줄을 인쇄하고 delline 함수를 사용하여 바로 위 줄을 지운 다음 한 줄을 다시 인쇄하여 함수 실행 결과를 표시했습니다.

    고톡시()

이 방법이 작동하는 방식은 두 개의 인수를 취한 다음 이 두 매개변수를 사용하여 창의 특정 지점으로 커서를 이동하는 것입니다.

암호:

 #include #include int main() { int a = 100, b = 50; gotoxy(a,b); printf('Cursor Position has been changed.'); return 0; } 

산출

 The cursor position has been changed. ................................................................... Process executed in 1.11 seconds Press any key to continue. 

설명:

위의 코드에는 두 개의 헤더 파일인 stdio.h 및 conio.h가 포함되어 있으며, 그 후 두 개의 정수 값을 선택하여 gotoxy() 함수에 대한 매개 변수로 제공했습니다. 프로그램이 실행되었습니다.

    wherey() 및 wherex()

이 함수는 현재 커서의 X 및 Y 좌표에 대한 정보를 제공합니다. 여기서 y()는 현재 출력 화면에서 커서의 y 좌표를 제공하는 반면, wherex()는 현재 출력 화면에서 커서의 x 좌표를 표시합니다.

암호:

 #include #include int main() { int x, y; x = wherex(); y = wherey(); cprintf('

The Coordinates of X and Y are - (%d, %d)', x, y); return 0; } 

산출

난수 생성 자바
 The Coordinates of X and Y are- (1,2) ................................................................... Process executed in 1.11 seconds Press any key to continue. 

설명:

두 개의 헤더 파일 stdio.h 및 conio.h는 두 개의 정수 x와 y를 가져와 x에 wherex() 값과 y에 wherey() 값을 저장하기 전에 위 코드에 포함되었습니다. 다음으로 활성 화면에서 포인터의 현재 x 및 y 좌표를 나타내는 x 및 y 값을 인쇄했습니다.