复制内容到剪贴板
代码:
[color=blue]-(dearvoid@LinuxEden:tty3)-(~/tmp)-
[26047 0] #[/color] cat freopen.c
#include <stdio.h>
#include <unistd.h>
int
main()
{
FILE *fp;
char buf[1024];
char tty[32];
ttyname_r(fileno(stdin), tty, sizeof(tty));
fp = freopen("./freopen.c", "r", stdin);
fgets(buf, sizeof(buf), stdin);
printf("%s", buf);
fp = freopen(tty, "r", stdin);
fgets(buf, sizeof(buf), stdin);
printf("%s", buf);
return 0;
}
[color=blue]-(dearvoid@LinuxEden:tty3)-(~/tmp)-
[26047 0] #[/color] gcc freopen.c
[color=blue]-(dearvoid@LinuxEden:tty3)-(~/tmp)-
[26047 0] #[/color] ./a.out
#include <stdio.h>
This line is inputed by me.
This line is inputed by me.
[color=blue]-(dearvoid@LinuxEden:tty3)-(~/tmp)-
[26047 0] #[/color] o