字符串处理相关函数

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 );

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务