下面的代码不是修剪日期字符串。
string today_date = iGLib :: Trim(date,'/');
例如:今天的日期是“ 27/01/2020”所以我只想要27或01
我怎么只能在C ++中得到它。
使用split(date, '/')
。
std::vector<std::string> split(const std::string& s, char delimiter)
{
std::vector<std::string> tokens;
std::string token;
std::istringstream tokenStream(s);
while (std::getline(tokenStream, token, delimiter))
{
tokens.push_back(token);
}
return tokens;
}
取自here