C中的标准输入输出可以进行重定向到文件。
// echo_eof.c -- 重复输入,直到文件的结尾
#include <stdio.h>
int main(void)
{
int ch;
while ( (ch = getchar()) != EOF)
putchar(ch);
return 0;
}
>echo_eof.exe
>echo_eof.exe < echo_eof.c
>echo_eof.exe < echo_eof.c >tmp.txt
原文地址:http://www.cnblogs.com/stayathust/p/3816519.html