Lecture 4 String Functions
Lecture 4 String Functions
Seventh Edition
Figure 13-1 How to declare and initialize string variables and named constants
Figure 13-2 Problem specification and IPO chart for the Creative Sales program
Figure 13-3 How to use the extraction operator (>>) to get string input
16
The getline Function (cont’d.)
Figure 13-25 IPO chart for the annual income program (cont’d.)
An Introduction to Programming with C++, Seventh Edition 50
Removing Characters from a string
Variable
• You can use the erase function to remove one or
more characters from a string variable
• Syntax is:
– string.erase(subscript[, count]);
– subscript is position of first character you want to remove
– Optional count argument is an integer that specifies
number of characters you want removed
– If you omit count, function removes all characters from
subscript through end of string
Figure 13-30 Partial annual income program showing the replace function