本文共 284 字,大约阅读时间需要 1 分钟。
freopen可以代替在黑框中的输入输出
#includeusing namespace std;int main(){ freopen("1.in.txt","r",stdin); freopen("1.out.txt","w",stdout); int a,b; cin>>a>>b; cout< <
freopen()中的文件1.in.txt和1.out.txt要跟主文件在同一个目录下。
fclose()有两个好处:
(1)将缓存区中的内容立刻刷到磁盘文件里,避免文件没有写入;
(2)释放文件指针。转载地址:http://xosdi.baihongyu.com/