std::string查詢功能比較強大
阿新 • • 發佈:2020-12-18
技術標籤:c++語法
char szContent[] = { '\x00','\x00', '\x3f','\x00','\xf0','\x80','\x00','\x3f','\x00','\xf0','\x00','\x3f','\x00','\xf0' }; std::string strContent; for (int i = 0; i < sizeof(szContent); ++i) { strContent.push_back(szContent[i]); } char szKey[] = { '\x3f','\x00','\xf0','\x00' }; std::string strKey; for (int i = 0; i < sizeof(szKey); ++i) { strKey.push_back(szKey[i]); } auto pos = strContent.find(strKey); //返回7 cout << pos << endl;