... substring from a string
. The result is a new string
object that’s copied from the source string
. Figure 21.3 demonstrates substr
. The program declares and initializes a string
at line 8. Line 12 uses member function substr
to retrieve a substring from string1
. The first argument specifies the beginning subscript of the desired substring; the second argument specifies the substring’s length.
Get C++ How to Program, 10/e now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.