c/c++
xuxhing
这个作者很懒,什么都没留下…
展开
-
结构体字节对齐
原文出处: 【点击,进入原文页面】struct student{ char name[20]; int age; char sex; char phone[15];};struct student p1;sizeof(p1)=?这个很简单得出答案,即20+4+1+15=40Byte。如果将phone[15]改为phone[16],结果是44。难道不是41吗?转载 2013-07-23 09:19:47 · 362 阅读 · 0 评论 -
指针与数组
由于数组与指针在使用时、作为函数参数的时候可以互换,很容易引起混淆, 其实数组和指针绝大多数情况下都不一致。先把问题抛出来, 看如下示例代码test.cint test_arry[] = {0x1234, 0x5678};main.cextern int *test_arry;int main(void){ printf("%x", test_arry)原创 2013-07-23 12:47:42 · 444 阅读 · 0 评论