Question: 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
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.
the progoram wont read the file characters
code
//system libraries #include
//global constants only
//Functions prototypes here
//Program execution start here int main(int argc, char** argv) { //Declare variables here char filename[30]; string input; int i; ifstream in; ofstream out; //input //prompt the user enter the input file cout<<"Enter the name of the input file "; cin>>filename; in.open(filename); //if the file did not open if(in.fail()) { cout<<"input file did not open please check it "; return 1; } //prompt the user to enter the output file cout<<"enter output file name? "; cin>>filename; out.open(filename); getline(in,input); //print the characters while(in) {for(i=0;input[i]!='.';i++) if(isalpha(input[i])) if(i==0) out.put(toupper(input[i])); else out.put(tolower(input[i])); else out.put(input[i]); out<<". "; getline(in,input); } out.close(); in.close(); //Exit return 0; }
output
Enter the name of the input file content.txt enter output file name? content2.txt
RUN SUCCESSFUL (total time: 13s)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
