C언어 예제 - 표준입력을 표준출력으로 출력

Jmnote bot (토론 | 기여)님의 2020년 11월 2일 (월) 02:40 판 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

C언어 예제 - 표준입력을 표준출력으로 출력
  • stdin2out.c
#include <stdio.h>
#include <unistd.h>

int main() {
	char ch;
	while(read(STDIN_FILENO, &ch, 1) > 0) {
		printf("%c", ch);
	}
	return 0;
}
root@zetawiki:~# gcc stdin2out.c -o stdin2out.out
root@zetawiki:~# echo hello | ./stdin2out.out
hello
root@zetawiki:~# echo hello | ./stdin2out.out | ./stdin2out.out
hello
root@zetawiki:~# echo hello | ./stdin2out.out | ./stdin2out.out | ./stdin2out.out
hello
root@zetawiki:~# echo 안녕 | ./stdin2out.out
안녕

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}