65,211
社区成员
发帖
与我相关
我的任务
分享
std::istringstream istr(str);//str为包含那些数据的字符串
int year;
int month;
int day;
int hour;
int minute;
int second;
double data;
istr >> year;
istr.get();
istr >> month;
istr.get();
istr >> day;
istr >> hour;
istr.get();
istr >> minute;
istr.get();
istr >> second;
istr >> data;
template <typename _Elem>
vector<basic_string<_Elem> > Split(const basic_string<_Elem> &src, const basic_string<_Elem> &boundary, int nMax)
{
assert(boundary.length() > 0);
vector<basic_string<_Elem> > ret;
if (boundary.empty())
{
return ret;
}
basic_string<_Elem>::size_type from = 0, to = src.find(boundary);
int nCount = 1;
while (to != basic_string<_Elem>::npos)
{
ret.push_back(basic_string<_Elem>(src, from, to - from));
from = to + boundary.size();
to = src.find(boundary, from);
if (nMax != 0 && ++nCount >= nMax)
{
break;
}
}
ret.push_back(basic_string<_Elem>(src, from, basic_string<_Elem>::npos - from));
return ret;
}