C++分割字符串

例如:std::string path;   path = path + "*" + s2 + "*" + s4; 

如何得到s2和s4?

                size_t pos = _path.find("*");
		size_t size = _path.size();
		int cnt = 0;
		while (pos != std::string::npos)
		{
			if (cnt==0)
			{
				std::string x = _path.substr(0, pos);
				//resVec.push_back(x);
				setScreenShotPath(x);

				_path = _path.substr(pos + 1, size);
				pos = _path.find("*");
			}
			if (cnt==1)
			{
				std::string x = _path.substr(0, pos);
				//resVec.push_back(x);
				float fLove = atof(x.c_str());
				setTextureWidth(fLove);

				_path = _path.substr(pos + 1, size);
				pos = _path.find("*");
				fLove= atof(_path.c_str());
				setTextureHeight(fLove);
			}
			
			cnt++;

		}

  

原文地址:https://www.cnblogs.com/tangmiao/p/7809711.html