c++ find 要比较npos

    string jstr1 = R"({"result":{"lastestVersionComments":"","latestVersion":"V1.0.1.0B1.1001","statisticsTimeout":90,"heartBeat":43200,"reconnectInterval":-1,"priority":"-1"},"id":"2","jsonrpc":"2.0"})";
    if (jstr1.find("latestVersion") != string::npos) {
        std::cout << jstr1.find("latestVersion") << endl;
    }
    
    if (jstr1.find("latestBoot") != string::npos) {
        std::cout << jstr1.find("latestBoot") << endl;
    }
    if (jstr1.find("latestConfiguration") != string::npos) {
        std::cout << jstr1.find("latestConfiguration") << endl;

要用npos不要用大于0

posted @ 2022-07-08 10:34  cnchengv  阅读(26)  评论(0编辑  收藏  举报