总结位一句话:
#include <iostream>
using namespace std;
int main()
{
char str[] = "hello world";
char str1[] = { 'h','e','l','l','o','w','o','r','l','d' };
cout << sizeof(str) << " " << strlen(str) << endl;
cout << sizeof(str1) << " " << strlen(str1) << endl;
//sizeof指的是字节数,优先取决于你arr[n]里面n的值, (n*数据类型字) 节数为多少sizeof(arr)就是多少。
cout << sizeof(str) / sizeof(str[0]) << endl;
cout << sizeof(str1) / sizeof(str1[0]) << endl;
//sizeof字节大小指的是包括了 空格 和 '\0'字节,char类型为1, 2+10=12
//strlen是字符串长度指的是 指的是 hello world还有'\0' 10+1=11
return 0;
}