Question: Redo Listing 9.9, replacing the character array with a string object. The program should no longer have to check whether the input string fits, and

Redo Listing 9.9, replacing the character array with a string object. The program should no longer have to check whether the input string fits, and it can compare the input string to "" to check for an empty line.

Listing 9.9

Listing 9.9 static.cpp //static.cpp #include // constants const int Arsize = 10;

Listing 9.9 static.cpp //static.cpp #include // constants const int Arsize = 10; int main() { -- // function prototype void strcount (const char str); } using a static local variable } using namespace std; char input [Arsize]; char next; cout < < "Enter a line: "; cin.get (input, Arsize); while (cin) { cin.get (next); while (next != ' ') cin.get (next); strcount (input); cout < < "Enter next line (empty line to quit): "; cin.get (input, Arsize); } cout < < "Bye "; return 0; void strcount (const char str) { // string didn't fit! // dispose of remainder using namespace std; static int total = 0; int count = 0; // static local variable // automatic local variable cout < < "\"" < < str

Step by Step Solution

3.38 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

static2cpp using a static string include include include function prototype void strcou... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction Java Program Questions!