如何从一行字符串中得到字符串

how to get string from a line of strings?

本文关键字:字符串 一行      更新时间:2023-10-16

我有以下字符串:

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