0%

std::string插入字符串

使用replace函数

1
2
3
4
5
6
std::string str = "19700101T000000";
str.replace(4, 0, "-"); // 1970-0101T000000
str.replace(7, 0, "-"); // 1970-01-01T000000
str.replace(10, 1, " "); // 1970-01-01 000000
str.replace(13, 0, ":"); // 1970-01-01 00:0000
str.replace(16, 0, ":"); // 1970-01-01 00:00:00