#include <iostream> #include <fstream>//This library is for reading and writing
ID: 3618901 • Letter: #
Question
#include <iostream>
#include <fstream>//This library is for reading and writing files
#include <cstdlib>//Used this library because I used the exit command
using namespace std;
//These functions explained below
void spaces();
int main()
{
ifstream infile;
ofstream outfile;
char response;
do
{
infile.open("Sentences.txt");
if(infile.fail())
{
cout << "I could not open thatfile.";
exit(1);
}
outfile.open("Sentences_Clone.txt");
if(outfile.fail())
{
cout << "I could not open thatfile.";
exit(1);
}
char next;
while(!infile.eof())
{
infile.get(next);
while(' '== next)
{
infile.get(next);
if(' '== next)
{
//infile.get(infile);
}
infile.get(next);
outfile << next;
}
infile.close();
infile.clear();
outfile.close();
//Asks the user he would like to go again anything other than (Y ory) the program ends
cout << "Would you like to go again (Yor y): ";
cin >> response;
cout << endl;
}while(response == 'Y' || response== 'y');
return 0;
}
//This void function is for 2 statement spaces betweensentences
void spaces()
{
cout << endl << endl;
}
Explanation / Answer
please rate - thanks 1--don't need spaces function 2--ask the user for the input and output files, because if you sayyes do it again, you are going to use the same files (useless) 3--your inputting too many times and in the wrong place. youare inputting letters and never outputting them 4--you are never outputting the 1st character after a space I'm messaging you a corrected program
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.