#include <stdio.h>
typedef struct student
{
int num1;
double num2;
float num3;
char* name;
}student;
int fun1(int a1,int a2,student a3)
{
printf("0x%08x\n",&a3);
printf("0x%08x\n",&a2);
printf("0x%08x\n",&a1);
printf("----------------\n\n");
int c = a1 + a2 ;
int v1 =0,v2 = 3,v3 = 5;
printf("0x%08x\n",&v1);
printf("0x%08x\n",&v2);
printf("0x%08x\n",&v3);
printf("----------------\n\n");
printf("0x%08x\n",&c);
return c;
}
int main()
{
student s = {2,1000.3,3.0,'a'};
int r = fun1(2,5,s);
return 0;
}
OutPut:
0xfff6b94c
0xfff6b960
0xfff6b964
----------------
0xfff6b97c
0xfff6b978
0xfff6b974
----------------
0xfff6b980
本文通过一个具体的C语言程序示例介绍了如何定义结构体类型,并探讨了在函数中如何使用结构体变量作为参数进行传递。文章还展示了不同变量在内存中的地址输出,帮助理解函数调用过程中的内存布局。
4万+

被折叠的 条评论
为什么被折叠?



