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.
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;
}
Comments
Leave a comment