13.13 Ӽ̶һַеĸַδڴļf2.datСٰӴļ򣬽еСдĸΪдĸٴļf3.dat
#include <fstream>
using namespace std;
// save_to_fileӼ̶һַеĸļ
void save_to_file( )
{ofstream outfile(f2.dat);   
//ļoutfileʽ򿪴ļf2.dat
if(!outfile)
  {cerr<<open f2.dat error!<<endl;
exit(1);
  }
 char c[80];
 cin.getline(c,80);//Ӽ̶һַ
 for(int i=0;c[i]!=0;i++)               //ֱַ/0Ϊֹ
if(c[i]>=65 && c[i]<=90||c[i]>=97 && c[i]<=122)//ĸַ
{outfile.put(c[i]);                      //ĸַļf2.dat
cout<<c[i];}                            //ͬʱʾʾ
 cout<<endl;
 outfile.close();                         //رf2.dat
}

//Ӵļf2.datĸַеСдĸΪдĸٴf3.dat
void get_from_file()
{char ch;
 ifstream infile(f2.dat,ios::in|ios::nocreate); 
//ļoutfile뷽ʽ򿪴ļf2.dat
 if(!infile)
  {cerr<<open f2.dat error!<<endl;
   exit(1);
  }
ofstream outfile(f3.dat);
 //ļoutfileʽ򿪴ļf3.dat 
if(!outfile)
  {cerr<<open f3.dat error!<<endl;
   exit(1);
  }
while(infile.get(ch))//ȡַɹʱִĸ
  {if(ch>=97 && ch<=122)          //жchǷΪСдĸ
ch=ch-32;                    //СдĸΪдĸ
   outfile.put(ch);               //ôдĸļf3.dat
   cout<<ch;                      //ͬʱʾ
  }
cout<<endl;
infile.close( );                  //رմļf2.dat
outfile.close();                 //رմļf3.dat
}
int main( )
{save_to_file( );   
       //save_to_file( )Ӽ̶һַеĸļf2.dat
get_from_file( );   
   //get_from_file()f2.datĸַΪдĸٴf3.dat 
 return 0;
}