![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
字符串操作
风下残月
这个作者很懒,什么都没留下…
展开
-
stringstream常见用法介绍
stringstream常见用法介绍转载 2021-08-20 16:04:05 · 130 阅读 · 0 评论 -
int, string, char*, CString之间的转换
string转CString CString cstr; string str = "hello world"; str.format("%s",str .c_str()); char*转CString CString cstr; char* pbuf= "hello world"; str.format("%s",buf); string转char* string str = "hello world"; char* pbuf = str.c_str(); CString转string string原创 2021-08-20 09:37:29 · 94 阅读 · 0 评论 -
C++ string字符串分割
采用C语言中的strtok 函数来进行分割 strtok函数包含在头文件<string.h>中,对于字符数组可以采用这种方法处理。当然也可以将字符数组转换成字符串之后再使用法一。测试代码如下 int main() { string str= "a,b*c,d"; const char *sep = ",*"; //可按多个字符来分割 char *p; p = strtok((char*)str.c_str(), sep); while (p){ printf("%s ", p);原创 2021-08-11 17:17:53 · 4186 阅读 · 0 评论 -
将string字符串“10086,3433,1234”,以“,”分割开
功能:将string字符串“10086,3433,1234”,以“,”分割开,存到vector容器中 代码片段: int posstar = 0; size_t pos; pos = 0; vector<int> v; size_t flagpso = strport.find(',', 0); //"10086,3433,1234" --- 多端口情况 if (flagpso != string::npos) { while ((pos = strpor原创 2021-08-11 16:16:23 · 86 阅读 · 0 评论