我有这个字符串:
std::string date = "20121020";
我正在做:
std::cout << "** Date: " << date << "\n";
std::cout << "Year: " << date.substr(0,4) << "\n";
std::cout << "Month: " << date.substr(4,6) << "\n";
std::cout << "Day: " << date.substr(6,8) << "\n";
但我得到:
** Date: 20121020
Year: 2012
Month: 1020
Day: 20
注意月份应该是10
,不是1020
。立场是正确的,什么都试过了,是不是失败了?