字符串初始化时的注意点
1. 如果不是以'\0'结尾的char数组,去初始化string时一定要带上长度;而以'\0'结尾的char数组,则不需要.
char no_null[] = {'H', 'i'}; string str(no_null); //runtime error:not null-terminated. str: Hi烫烫烫hX? string str2(no_null, 2); char c_array[] = "Hi"; string str3(c_array); //this is right;
新战场:https://blog.csdn.net/Stephen___Qin