首页 > 其他 > 详细

指针与地址

时间:2015-11-04 21:29:15      阅读:239      评论:0      收藏:0      [点我收藏+]

#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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!