标准输入输出重定向
来源:百度文库 编辑:神马文学网 时间:2024/04/28 06:38:33
//#include
//#include
#include
#include
#include
//#include
int main(void)
{
#define STDOUT 1
int nul, oldstdout;
char msg[] = "This is a test\n";
char msg_in[]="stdin\n";
/* create a file */
nul = open("DUMMY.FIL", O_CREAT | O_RDWR);
/* create a duplicate handle for standard
output */
oldstdout = dup(STDOUT);
/*
redirect standard output to DUMMY.FIL
by duplicating the file handle onto the
file handle for standard output.
*/
dup2(nul, STDOUT);
dup2(nul, 0);
dup2(nul, 2);
/* close the handle for DUMMY.FIL */
close(nul);
/* will be redirected into DUMMY.FIL */
write(STDOUT, msg, strlen(msg));
write(0,msg_in,strlen(msg_in));
/* restore original standard output
handle */
dup2(oldstdout, STDOUT);
/* close duplicate handle for STDOUT */
close(oldstdout);
return 0;
}
//#include
#include
#include
#include
//#include
int main(void)
{
#define STDOUT 1
int nul, oldstdout;
char msg[] = "This is a test\n";
char msg_in[]="stdin\n";
/* create a file */
nul = open("DUMMY.FIL", O_CREAT | O_RDWR);
/* create a duplicate handle for standard
output */
oldstdout = dup(STDOUT);
/*
redirect standard output to DUMMY.FIL
by duplicating the file handle onto the
file handle for standard output.
*/
dup2(nul, STDOUT);
dup2(nul, 0);
dup2(nul, 2);
/* close the handle for DUMMY.FIL */
close(nul);
/* will be redirected into DUMMY.FIL */
write(STDOUT, msg, strlen(msg));
write(0,msg_in,strlen(msg_in));
/* restore original standard output
handle */
dup2(oldstdout, STDOUT);
/* close duplicate handle for STDOUT */
close(oldstdout);
return 0;
}
标准输入输出重定向
Linux下的重定向输入输出(转自黑基网,http://www.hackbase.com/lib/2005-06-09/7836.html)
dos重定向
jsp和servlet重定向
301重定向的实现方法
301 Redirect 永久重定向的实现
301 Redirect 永久重定向的实现
使用301重定向 - 51windows.Net
重定向和转发的区别
转发与重定向的区别
换域名之301永久重定向
ASP .NET下的301重定向
用户配置文件漫游与文件夹重定向不是一回事
移除 Google 搜索结果页面的重定向脚本
log4j 中过滤及重定向日志信息
301重定向的实现方法-月光博客
IIS 301重定向到www.开头的域名
301重定向有我们需要注意的地方?
全站完美无缝301重定向的方法
输入输出 2007
C++输入输出
详尽分析:AV终结者采用重定向劫持技术 — IT技术
动态链接库的数据及动态链接库重定向,译自MSDN
SEO 301重定向-301永久转向页面(ASP PHP JSP)