Extracting a Substring from a String: substr()
substr() extracts part of a string, leaving the original string unchanged. It takes two parameters of type string::size_type: the first is the position to start extracting, and the second is the number of characters to extract. It returns a substring consisting of the extracted characters. If you omit the second parameter, substr() will extract characters from the starting position and be continuing to the end of the string.
Syntax: result_string = source.substr(starting_pos,numchars);
Post A Comment:
0 comments: