C putchar() 표준 출력 장치에 문자 출력 함수
C언어 출력 함수인 putchar()은 표준 출력 장치로 문자 하나를 출력합니다.
- 헤더: stdio.h
- 형태: int putchar(int c);
- 인수: int c 출력할 문자
- 반환: int출력한 문자를 반환합니다.
C언어 putchar() 함수 예제
#include <stdio.h>
int main( void)
{
char ch_key;
while( 1){
ch_key = getchar();
if ( EOF == ch_key){
printf( "\nquit\n");
break;
} else {
putchar( putchar( ch_key)); // 입력받은 문자열과 putchar() 반환값을 출력
}
}
return 0;
}
C언어 putchar() 예제 실행 결과
]$ ./a.out
badayak.com <- badayak.com 입력 후 엔터
bbaaddaayyaakk..ccoomm
jwmx.tistory.com <- jwmx.tistory.com 입력 후 엔터
ffoouurrmm..ffaalliinnuuxx..ccoomm
<- ctrl-D 를 입력
quit
]$
'컴퓨터 > 프로그래밍' 카테고리의 다른 글
C언어 gets 함수 표준 장치로부터 문자열 입력 (0) | 2020.03.13 |
---|---|
C언어 getchar 함수 표준 입력 장치로부터 문자 하나 입력 (0) | 2020.03.12 |
C언어 memcmp 함수 두개의 메모리 변수에 대한 내용 비교 (0) | 2020.03.12 |