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