#include <iostream>
#include <string>
using namespace std;
int main()
{
char* str = "Hello";
char str1[] = "hello";
int data[] = {1,2};
cout << sizeof(str)<<endl;
cout << sizeof(str1)<<endl;
cout << sizeof(data);
return 0;
}
str 指向文字常量区,内容不可修改。
sizeof(str)为指针大小,sizeof(str1)为占用内存大小,sizeof(data)为占用内存大小。