//写出以下程序的输出结果
#include <stdio.h>
struct type
{
int x;
char c;
};
func(struct type b)
{
b.x=20;
b.c='y';
}
void main()
{
struct type a ={10,'x'};
func(a);
printf("%d,%c",a.x,a.c);
}
得传地址才能改变
值传递不能改变
这样就行了
//写出以下程序的输出结果
#include <stdio.h>
struct type
{
int x;
char c;
};
void func(struct type *b)
{
b->x = 20;
b->c = 'y';
}
void main()
{
struct type a = {10, 'x'};
func(&a);
printf("%d,%c", a.x, a.c);
}