Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- usb2.0
- fscanf
- context
- 속도저하
- interrupt context
- 젠킨스
- 환경 변수
- DMA
- intents
- ubuntu
- fprintf
- gparted
- 멀티프로세싱
- memcmp
- 문자형 디바이스 파일
- 디스크립터
- 디스크 축소
- sprintf
- 소캣
- sscanf
- jenkins
- layouts
- activities
- pagefile.sys
- interrupt handler
- Shared Folder
- HDR
- 프레임버퍼
- context switch
- makefile
Archives
- Today
- Total
do{학습}while
c) getchar() 본문
기능 요약
unsigned char 문자를 입력받아 정수(int)로 변환해 반환
입력 시에 버퍼를 비워주기 위한 용도로도 사용이 됩니다.
헤더파일
#include <stdio.h> // C++ 의 경우 <cstdio>
원형
int getchar(void);
반환값
읽어들린 문자를 정수(int)로 반환
만약 파일 끝에 도달하거나 에러가 발생 EOF 반환
주의 사항
예시 코드
/* 한 문자를 읽는다.*/
#include <stdio.h>
int main() {
int ch = getchar();
printf("문자 : %c \n", ch);
return 0;
}
/* 버퍼 비우기 */
#include <stdio.h>
int main() {
int i;
char c;
scanf("%d", &i);
getchar();
scanf("%c", &c);
printf("입력한 문자 : %c \n", c);
return 0;
}'C & C++ > c언어 표준함수' 카테고리의 다른 글
| c) strcat() (0) | 2024.05.28 |
|---|---|
| c) strstr() (0) | 2024.05.28 |
| c) puts() (0) | 2024.05.28 |
| c) fgets() (0) | 2024.05.28 |
| c) memcmp() (0) | 2024.05.27 |