Redo Listing 9.9, replacing the character array with a string object. The program should no longer have
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 it can compare the input string to "" to check for an empty line.
Listing 9.9
Transcribed Image Text:
Listing 9.9 static.cpp
//static.cpp
#include
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: \n";
cin.get (input, Arsize);
while (cin)
{
cin.get (next);
while (next != '\n')
cin.get (next);
strcount (input);
cout << "Enter next line (empty line to quit): \n";
cin.get (input, Arsize);
}
cout << "Bye\n";
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 <<"\" contains ";
while (*str++)
// go to end of string
count++;
total + count;
cout << count <<" characters\n";
cout << total << " characters total\n";
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 66% (9 reviews)
static2cpp using a static string include include include function prototype void strcou...View the full answer
Answered By
Dansteve Matoke
As a consequence of more than three years of experience in ACADEMIC WRITING, I have vast, diverse knowledge and impeccable grammar. I guarantee the quality of my work across multiple fields. I intend to precisely meet the clients' expectations. Let's work together to achieve exceptional grades.
0.00
0 Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
Write a bash script to check whether the input number is EVEN, ODD, or neither EVEN nor ODD.
-
Check whether organisms 1 and 2 differ and compare with Section 8.6, Exercise 39. One organism has 8 mutations in 1 million base pairs, a second has 18 in 1 million, and a third has 28 in 1 million....
-
Check whether organisms 2 and 3 differ and compare with Section 8.6, Exercise 40. One organism has 8 mutations in 1 million base pairs, a second has 18 in 1 million, and a third has 28 in 1 million....
-
Francis and Peter are in a partnership sharing profits and losses in the ratio 3:2. The following is their trial balance as at 30 September 2020. particulars D ebit C redit Buildings (cost: RM...
-
In recent years, a new theory of real business cycles (or RBCs) has been proposed (this approach is further analyzed in Chapter 31). RBC theory suggests that business fluctuations are caused by...
-
Write and run an SQL CREATE TABLE statement to create the CUSTOMER_03 table.
-
Summarize some of the unique problems encountered in service systems, and describe some of the approaches used for scheduling service systems. LO.1
-
J&J Snack Foods Corp. is a national manufacturer and distributor of snack foods and frozen beverages. Among its brands are ICEE, SuperPretzel, and Cinnabon CinnaPretzel. Adapted versions of the...
-
A company purchased $3,700 of merchandise on July 5 with terms 3/10, n/30. On July 7, it returned $410 worth of merchandise. On July 8, it paid the full amount due. The amount of the cash paid on...
-
a. Formulate and solve a linear programming model for this problem. b. What is your resulting recommendation to the school board? After seeing your recommendation, the school board expresses concern...
-
Fuel cells similar to the PEM cell of Example 1.4 operate with a mixture of liquid water and methanol instead of hydrogen; the anode is placed in direct contact with the liquid fuel. Oxygen (species...
-
There are three salts that contain complex ions of chromium and have the molecular formula CrCl 3 ? 6H 2 O. Treating 0.27 g of the first salt with a strong dehydrating agent resulted in a mass loss...
-
Revise the following sentences to emphasize the perspective of the audience and the you view. Our warranty goes into effect only when we have received the products registration card from the...
-
Part 1 of 4 05 points abook Print References Required information Problem 24-2A (Algo) Payback period, accounting rate of return, net present value, and net cash flow calculation LO P1, P2, P3 [The...
-
Keenan Music's CEO has been pondering about the recent proposal of the Specialty Guitar Project. The accountant has done a capital budgeting analysis on the project and outlined the conditions that...
-
On July 1, 2025, Sheridan Co. pays $15,000 to Blue Spruce Insurance Co. for a 2-year insurance contract. Both companies have fiscal years ending December 31. (a1) Journalize the entry on July 1 and...
-
A CU triaxial test with c = 20 psi is performed on a sand and a deviator stress of 80 psi fails the specimen. Previous tests revealed that the effective friction angle for this sand is 35. Calculate...
-
Haliburton Mills Inc. is a large producer of men's and women's clothing. The company uses standard costs for all of its products. The standard costs and actual costs for a recent period are given...
-
In Exercise, match the function with its graph from choices AF. (x) = log 2 (-x) A. B. C. F. E. D. HE
-
The cash records of Holly Company show the following four situations. 1. The June 30 bank reconciliation indicated that deposits in transit total $720. During July, the general ledger account Cash...
-
For a tree T, let n I denote the number of its internal nodes, and let n E denote the number of its external nodes. Show that if every internal node in T has exactly 3 children, then n E = 2n I +1.
-
Let T be a (possibly improper) binary tree with n nodes, and let D be the sum of the depths of all the external nodes of T. Describe a configuration for T such that D is Ω(n 2 ). Such a...
-
Consider the example of a breadth-first traversal given in Figure 8.15. Using the annotated numbers from that figure, describe the contents of the queue before each pass of the while loop in Code...
-
*please calculate irr in excel
-
Which of the following would not be a period cost? Research and development Direct materials Office supplies Advertising costs
-
\ table [ [ Activity Cost Pool,Activity Measure,Total Cost,Total Activity ] , [ Machining , Machine - hours,$ 3 3 0 , 0 0 0 , 1 5 , 0 0 0 MHs ] , [ Machine setups,Number of setups,$ 3 0 0 , 0 0 0 , 5...
Study smarter with the SolutionInn App