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

Jmnote (토론 | 기여)님의 2017년 11월 23일 (목) 01:01 판 (새 문서: ==개요== ;C언어 예제 - 표준입력을 표준출력으로 출력 * stdin2out.c <source lang='c'> #include <stdio.h> #include <unistd.h> int main() { char ch; while(read(STDI...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

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

2 같이 보기

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