Similar Books


    No books found

Title
Chapter: 3 / Q: e.g3.2.3.1
A string represents a sequence of characters, so we can use a string as the expression in a range for. As a simple example, we can use a range for to print each character from a string on its own line of output
Chapter: 3 / Q: e.g3.2.3.2
As a somewhat more complicated example, we’ll use a range for and the ispunct function to count the number of punctuation characters in a string
Chapter: 3 / Q: e.g3.2.3.3
To convert the whole string we need to call toupper on each character and put the result back in that character
Chapter: 3 / Q: e.g3.2.3.4
The following example uses the subscript operator to print the first character in a string
Chapter: 3 / Q: e.g3.2.3.5
So long as the string is not const (§ 2.4, p. 59), we can assign a new value to the character that the subscript operator returns. For example, we can capitalize the first letter as follows
Chapter: 3 / Q: e.g3.2.3.6
As a another example, we’ll change the first word in s to all uppercase
Chapter: 3 / Q: e.g3.2.3.7
As an example, let’s assume we have a number between 0 and 15 and we want to generate the hexadecimal representation of that number. We can do so using a string that is initialized to hold the 16 hexadecimal “digits”
Chapter: 3 / Q: e.g3.3.1
To use a vector, we must include the appropriate header. In our examples, we also assume that an appropriate using declaration is made
Chapter: 3 / Q: e.g3.3.2
In the case of vector, the additional information we supply is the type of the objects the vector will hold
Chapter: 3 / Q: e.g3.3.1.1
We can default initialize a vector (§ 2.2.1, p. 44), which creates an empty vector of the specified type
total questions: 591

Questions

591

Views

A PHP Error was encountered

Severity: Warning

Message: Undefined property: stdClass::$TotalViews

Filename: books/book.php

Line Number: 411

Best Answers

299

Points

5