Answer to Question #332859 in C++ for Tkh^2

Question #332859

Write a program to read the content of a file and copy its content to another file after converting all the capital case letters in the file to small case letters. 


1
Expert's answer
2022-04-23T18:13:35-0400






Notice before will run program please don't forget create file


#include <iostream>
#include <fstream>
#include  <string>
using namespace std;
int main() {
  cout<<"Please enter file name and type(.txt...):";
  string fnm;
  cin>>fnm;
  ifstream inp(fnm);
  if(!inp)//
  {
    cout<<"File doesnt exist!!\n";
    return 0;
  }
  string copyName="CopyFile.txt";//There is name of copy file
  string line;//each line read
  ofstream of(copyName,ios::trunc);
  while(getline(inp,line))
    {
      //capital cae letter to small case letter
      for(unsigned i=0;i<line.size();i++)
        line[i]=tolower(line[i]);
      of<<line<<"\n";
    }
  inp.close();
  of.close();
  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS