如何从一行字符串中得到字符串
how to get string from a line of strings?
我有以下字符串:
"hw_core_detectionhook::Iocard const*"
我必须只得到第一部分,即空格之前的所有文本,即我只需要"hw_core_detectionhook::Iocard"
部分。
std::stringstream ss;
ss << "hw_core_detectionhook::Iocard const*";
std::string s;
ss >> s;
std::cout << s;
输出:hw_core_detectionhook::Iocard
查看完整的在线演示:http://www.ideone.com/w9l1C
s.substr(0,s.find_first_of(" "));
相关文章:
- 将字符串存储到文件下一行的变量中
- 在 c++ 中将uint8_t数组转换为字符串以在一行中打印
- 如何从一行 C++ 中提取两个字符串
- 迭代一行(字符串)C++ 中的每个单词
- 在每个特定字符串之后插入下一行
- 在一行中输入具有其他输入类型的多个单词字符串
- cout 用于仅打印最后一行的 2D 字符串矢量
- 创建一个字符串变量,并在同一行上要求输入
- 带有新行的字符串仅保存在一行中
- 在同一行中读取混合输入(字符串/浮点数),并将其存储在数组中
- 是否可以遍历文本文件行并使用字符串流来解析每一行
- 在字符串中的一行中搜索大于0的数字
- gvim 换行应该结束当前字符串并在下一行开始一个新的字符串
- 从文件中读取一行并将其放入字符串中(使用 fstream)
- 从文件中读取一行,并在其中搜索字符串(c++)
- 获取一行字符串并转换为浮点列表
- 字符串迭代器与读取每一行不兼容
- 用c++将文件中的一行文本复制到字符串中
- 如何知道文本文件中的字符串是否在第一行?[C++ ]
- cout 字符串和向量在同一行中