使用stirng的substr函数, 其中第一个参数是起始位置, 第二个参数是子串的长度
#include <iostream>
#include <string>
using namespace std;
int main() {
string a = "20170816";
string b = a.substr(0,4);
string c = a.substr(4,2);
string d = a.substr(6,2);
cout << b << endl << c << endl << d << endl;
}