- 从字符串的长度:——>空字符的长度为0,空格符的长度为1
char a[] = "\0";
char b[] = " ";
cout << strlen(a) << endl; //0
cout << strlen(b) << endl; //1
- 虽然输出于屏幕是一样的,但是他们还是有区别的:
char crr[] = "a b"; //输出是a b
char brr[] = "a\0b"; //输出是a --------->因为遇到'\0'代表结束
cout << strlen(crr) << endl;
cout << strlen(brr) << endl;