substr
Syntax:
#include <string> string substr( size_type index, size_type num = npos ); The substr() function returns a substring of the current string, starting at index, and num characters long. If num is omitted, it will default to string::npos, and the substr() function will simply return the remainder of the string starting at index. For example: string s("What we have here is a failure to communicate"); string sub = s.substr(21); cout << "The original string is " << s << endl; cout << "The substring is " << sub << endl; displays The original string is What we have here is a failure to communicate The substring is a failure to communicate |