freopen()的重定向打开或者关闭

加入有一个文本文件为:text.txt.我们打开这个文件,读入其中的数据。所使用的代码为:

freopen("text.txt","r",stdin);

对应的关闭语句为:

freopen("CON", "r", stdin);

往文件中写数据的代码为:

freopen("text.txt","w",stdout);

对应的关闭语句为:

freopen("CON", "w", stdout);

以上只针对于Windows环境下^ _ ^

你可能感兴趣的:(freopen()的重定向打开或者关闭)