“c++判断某个字串是否有关键字”代码示例:

1
2
3
4
5
6
7
8
9
10
11

std::string& aJSONData="tsddsgsgsgsgsgsdgsgsg";
std::string json_data = aJSONData.c_str();
std::string::size_type idx_exit_sdl = json_data.find("send_to_exit_sdl_hmi");
if(idx_exit_sdl != std::string::npos) {
// Success!!
std::cout<<"Start to exit sdl app!!"<<std::endl;
send_exit_sdl_message_to_ivi();
} else {
// Fail!!!!!
}