sizeof的用法全

来源:互联网 发布:苹果手机连不起4g网络 编辑:程序博客网 时间:2024/05/16 17:50

1、统计数组:

int a[10];char b[10];cout << sizeof(a) << endl;//40cout << sizeof(b) << endl;//10

2、统计指针:

char *str = "hello fzz";int a = 9;int *i = &a;double d = 1.00;double *ptrD = &d;cout << sizeof(str) << endl;//4cout << sizeof(a) << endl;//4cout << sizeof(i) << endl;//4cout << sizeof(d) << endl;//8cout << sizeof(ptrD) << endl;//4



原创粉丝点击