C++ programming I need help writing a program that will interactively prompt the
ID: 3610617 • Letter: C
Question
C++ programming I need help writing a program that will interactively prompt the user for the name of an input file and read it. I needto be able to open the input file (using an input filestreamvariable) and display the contents of the file so that each word ona line is separated by exactly 1 blank space and there are no morethan 50 characters per line (including blanks). It has to displaythe maximum number of whole words that fit on a line with outexceeding 50 characters and without leaving an extra blank afterthe end of a sentence. The datafile that will be opened will contain: Jack andJill went up the hIll 2 fetcha pail ofstill water. Jack fell down and broke his crown and Jillcam tumbling after! C++ programming I need help writing a program that will interactively prompt the user for the name of an input file and read it. I needto be able to open the input file (using an input filestreamvariable) and display the contents of the file so that each word ona line is separated by exactly 1 blank space and there are no morethan 50 characters per line (including blanks). It has to displaythe maximum number of whole words that fit on a line with outexceeding 50 characters and without leaving an extra blank afterthe end of a sentence. The datafile that will be opened will contain: Jack andJill went up the hIll 2 fetcha pail ofstill water. Jack fell down and broke his crown and Jillcam tumbling after!Explanation / Answer
//Hope this will helpyou.. #include #include #include using namespace std; int main () { int count=0; string line; char ch; char file[100]; coutfile; ifstream myfile (file); if (myfile.is_open()) { while (! myfile.eof() ) { myfile.get(ch); line=""; while(ch !=' ' && !myfile.eof() && ch!=' ') { line += ch; myfile.get(ch); } if(line!="") { if( ((count + line.length())Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.