指针与地址

 1 #include <iostream>
 2 using namespace std;
 3 int main() {
 4     char s1[] = "Hello World";      //字母10位,空格1位,结尾''占一位
 5     char *s2 = "Hello World";      //一个指针占4位
 6     cout << "size of s1: " << sizeof(s1) << endl;       //12
 7     cout << "size of *s1: " << sizeof(*s1) << endl;    //*s1='H',长度为1
 8     cout << "size of &s1: " << sizeof(&s1) << endl;    //4
 9     cout << "size of s2: " << sizeof(s2) << endl;      //4
10     cout << "size of *s2: " << sizeof(*s2) << endl;     //1
11     cout << "size of &s2: " << sizeof(&s2) << endl;     //4
12 }
原文地址:https://www.cnblogs.com/jfl-xx/p/4937329.html