Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please fix my C++ code!!!! Thank you in advance! 12.7: Sentence Filter Write a p

ID: 3913488 • Letter: P

Question

Please fix my C++ code!!!! Thank you in advance!

12.7: Sentence Filter Write a program that asks the user for two file names. The first file will be opened for input and the second file will be opened for output. (It will be assumed that the first file contains sentences that end with a period.) The program will read the contents of the first file and change all the letters to lowercase except the first letter of each sentence, which should be made uppercase. The revised contents should be stored in the second file. Prompts And Output Labels. Input Specification.

Explanation / Answer

HIIII......Please find this code its working fine

//C++ CODE

#include<fstream>

#include<string>

#include<iostream>

using namespace std;

void readNWrite();

string inF,outF;

int main()

{

cout<<"Enter the file name with full path: ";

cin>>inF;

ifstream f(inF.c_str());

if(!f)

{

cout<<"Input file doesn't exist.";

return 0;

}

cout<<" Input the file name with full path: ";

cin>>outF;

readNWrite();

return 0;

}

void readNWrite()

{

char ch;

ofstream of;

of.open(outF.c_str());

if(!of) {

cout<<"Output file creation failed!";

return;

}

fstream file(inF.c_str(), fstream::in);

int flag1=0 ;

while (file >> noskipws >> ch)

{

if(ch=='.')

flag1 = 1;

if(isalpha(ch) && flag1==1)

{

of<<(char)toupper(ch);

flag1 = 0;

}

else

{

if(isupper(ch))

of<<(char)tolower(ch);

else

of<<ch;

}

  

}

ifstream f(outF.c_str());

if(f)

cout<<"Output File was created successfuly!";

else

cout<<"Error in creating the file.";

}