文件流

#include "stdafx.h"
#include<string>
#include<fstream>
#include<iostream>
#include<iomanip>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
 ifstream fin;
 ofstream fout;
 int cutoff=700;
 int income ,tax;
 fin.open("E:\\mario.txt");
 fout.open("E:\\result.txt");
 while(fin>>income){
 if(income<cutoff)
 fout<<income<<endl;
 };
 fin.close();
 fout.close();






 return 0;
}

 
 
 

 

 
  
  
  
  
fin>>从文件中读取流;

fout<< 将流的内容写入;

为了防止大脑老化额外练习:

操作符的使用,输出日历样式。

string str[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
;
for(int i=0;i<7;i++)
cout<<"  "<<str[i];
cout<<endl;
int day=2;
cout<<setw(5)<<" "<<setw(5)<<"";
for(int i=1;i<=31;i++){
cout<<right<<setw(5)<<i;
if((day+i)%7==0)cout<<endl;
}

 


你可能感兴趣的:(文件流)