使用文件输入与输出

来源:互联网 发布:淘宝女装春装2015新款上市 编辑:程序博客网 时间:2024/06/14 17:05
#include <stdio.h> #include <iostream> int main() { int a,b; freopen("in.txt","r",stdin); //输入重定向,输入数据将从in.txt文件中读取 freopen("out.txt","w",stdout); //输出重定向,输出数据将保存在out.txt文件中 while(cin>>a>>b) cout<<a+b<<endl; // 注意使用endl fclose(stdin);//关闭文件 fclose(stdout);//关闭文件 return 0; }