假设以下代码运行环境为32位系统,其中,__attribute__((packed))的作用是告诉编译器取消结构在编译过程中的优化对齐,按照实际占用字节数进行对齐。代码段1:structstudent1{charname[10];longsno;charsex;floatscore[4];}__attribute__((packed))*p1,a1,b1;代码段2:unionstudent2{charname[10];longsno;charsex;floatscore[4];}*p2,a2,b2;siz
欢迎免费使用小程序搜题/刷题/查看解析,提升学历,成考自考报名,论文代写、论文查重请加客服微信skr-web
假设以下代码运行环境为32位系统,其中,__attribute__((packed))的作用是告诉编译器取消结构在编译过程中的优化对齐,按照实际占用字节数进行对齐。代码段1:structstudent1{charname[10];longsno;charsex;floatscore[4];}__attribute__((packed))*p1,a1,b1;代码段2:unionstudent2{charname[10];longsno;charsex;floatscore[4];}*p2,a2,b2;sizeof(structstudent1)、sizeof(unionstudent2)的结果分别是______。
A.248和128
B.31和31
C.31和16
D.16和16
正确答案C
×
提示:小程序已经收录此题,请在小程序查看名师解析。翰林刷小程序提供搜题,刷题,助你轻松通过考试