to_string
c_str
Returns a pointer to an array that contains a null-terminated sequence of characters (i.e., a C-string) representing the current value of the string object.
string str("Please split this sentence into tokens");
char *cstr = new char[str.length()+1];
strcpy(cstr, str.c_str());
char * p = std::strtok (cstr," ");
while (p!=0)
{
std::cout << p << '\n';
p = std::strtok(NULL," ");
}
包含头文件<cstring>
strtok
分割字符串
char * strtok ( char * str, const char * delimiters );
strcat
Concatenate strings
char * strcat ( char * destination, const char * source );
strcpy
Copy string
char * strcpy ( char * destination, const char * source );