测试C语言文件输出输入重定向时return上面的system(“pause)失效 解决方法 将标准输入输出流定向回控制台即可
int main(void)
{
int ch;
FILE *file = NULL;
file = freopen("C:\\Users\\a\\Desktop\\111.txt","r",stdin);
while((ch = getchar())!=EOF)
putchar(ch);
freopen("CON","r",stdin);//Linux中CON变更为/dev/tty
system("pause");
return 0;
}
本文介绍了一种解决C语言程序中使用system(pause)命令在进行输入输出重定向时失效的问题的方法。通过将标准输入输出流重新定向回控制台,可以确保system调用正常工作。
1686

被折叠的 条评论
为什么被折叠?



