代码拉取完成,页面将自动刷新
#include<stdio.h>
//#pragma pack(2)
//struct s
//{
// char a;
// int b;
// double c;
//};
//#pragma pack()
//int main()
//{
// printf("%d\n", sizeof(struct s));
//
// return 0;
//}
//offsetof:计算结构体变量的偏移量
//#include<stdio.h>
//#include<stddef.h>
//struct s
//{
// char a;
// int b;
// double c;
//};
//int main()
//{
// printf("%d\n", offsetof(struct s, a));
// printf("%d\n", offsetof(struct s, b));
// printf("%d\n", offsetof(struct s, c));
// return 0;
//}
//结构体传参
struct s
{
int a[10];
int b;
};
struct s s1 = { {1,2,3,4,5},99 };
void print1(struct s s1)
{
printf("%d\n", s1.b);
}
void print2(struct s*ps1)//最好传地址调用
{
printf("%d\n", ps1->b);
}
int main()
{
print1(s1);
print2(&s1);
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。