Chinaunix首页 | 论坛 | 博客
  • 博客访问: 157641
  • 博文数量: 76
  • 博客积分: 1513
  • 博客等级: 上尉
  • 技术积分: 755
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-25 15:15
文章分类

全部博文(76)

文章存档

2012年(2)

2011年(74)

我的朋友

分类: C/C++

2011-11-25 21:14:04

  1. #include<iostream>

  2. #include<fstream>

  3. #include<String>

  4. using namespace std;

  5.  

  6. int main()

  7. {

  8.     ifstream fin;

  9.     ofstream fout;

  10.     string str1,str2;

  11.     char ch;

  12.     int length;

  13.     cout<<"Input the infilename:"<<endl;

  14.     cin>>str1;

  15.     fin.open(str1.c_str(),ifstream::binary|ifstream::in);

  16.     fin.seekg(0,ifstream::end);

  17.     length=fin.tellg();

  18.     fin.seekg(0,ifstream::beg);

  19.     cout<<length<<endl;

  20.     char* in_array=new char[length];

  21.     fin.read(in_array,length);

  22.     cout<<"Input the char to change case:"<<endl;

  23.     cin>>ch;

  24.     for(int i=0;i<length;i++)

  25.     {

  26.             if(in_array[i]==ch)

  27.             in_array[i]-=32;

  28.             cout<<in_array[i]<<" ";

  29.     }

  30.     cout<<"Input the outfilename:"<<endl;

  31.     cin>>str2;

  32.     fout.open(str2.c_str(),ofstream::binary|ofstream::out);

  33.     fout.write((char*)in_array,length);

  34.     fin.close();

  35.     fout.close();

  36.     delete[] in_array;

  37.     return 0;

  38.     


  39. }
阅读(590) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~