问题遇到的现象和发生背景:在课本的序章讲解STL string 类的例题中出现了如下伪代码:
char cstr[] = "China!Great Wall";
string s1(cstr); //s1:China!Great Wall
string s2(s1); //s2:China!Great Wall
string s3(cstr, 7, 11); //s3:Great Wall
string s4(cstr, 6); //s4:China!I
string s5(5, 'A'); //s5:AAAAA
}
然后我发现s4的结果 并不是明白,所以我去带到ide环境
#include<iostream>
#include<string>
using namespace std;
void main(){
char cstr[] = "China!Great Wall";
string s1(cstr); //s1:China!Great Wall
string s2(s1); //s2:China!Great Wall
string s3(cstr, 7, 11); //s3:Great Wall
string s4(cstr, 6); //s4:China!
string s5(5, 'A'); //s5:AAAAA
}
运行结果及报错内容

我想要达到的结果:理解s4的结果以及解决代码问题