freopen()使用方法重定向版

代码如下

#include<iostream>
#include<cstdio>
using namespace std;
int main ()
{
char a[100];
#define io//提交时删除这个 
#ifdef io 
freopen("a.txt","r",stdin);
//在程序文件 下创建a.txt 导入题目数据到里面 
 
//freopen("aa.txt","w",stdout);
//会自动在.cpp所在文件夹下创建一个aa.txt存入输出的数据
#endif
cin>>a;
cout<<a<<endl;
    return 0;
}           

猜你喜欢

转载自www.cnblogs.com/maxv/p/11734867.html