目录
一.结构体参数传递
二.结论
三.视频教程
一.结构体参数传递
结构体变量可以作为函数参数和函数返回值。
举例:
#include <stdio.h>
struct test {
int a;
int b;
};
struct test func(struct test c)
{
c.a = 3;
c.b = 4;
return c;
}
int main(void)
{
struct test x;
struct test z;
x.a = 1;
x.b = 2;
z = func(x);
printf("z.a is %d,z.b is %d\n",z.a,z.b);
return 0;
}
二.结论
如果结构体变量可以作为函数参数,那么俩个相同类型的结构体变量直接可以只用赋值号进行赋值。
三.视频教程
71.结构体参数传递_哔哩哔哩_bilibili