c语言中的struct 做函数参数 时 传指针的方法

include

include

include

define Size 20

typedef struct {
char name[10];
char sex ;
int grade;
}Stu,*StuP;//似乎*StuP 来声明一个指针变量的这种方法在dev中并不好用,会报错。

//typedef struct Stu* Stup;

Stu stu2[Size] ;

void print( Stu* stu1 ){
printf(“%c %s %d “,stu1->sex,(stu1)->name,(stu1)->grade);// 指针变量 stu1-> sex 这种方式和 (*stu1).sex是等效的。
}

void arrprint(Stu* stu1,int len){ //传递结构体和结构体数组都是用指针。
for(int i = 0;i

include

include

include

define Size 20

typedef struct {
char *name ;
char sex ;
int grade;
}Stu,*StuP;//似乎*StuP 来声明一个指针变量的这种方法在dev中并不好用,会报错。

//typedef struct Stu* Stup;

Stu stu2[Size] ;

/void print( Stu stu1 ){
printf(“%c %s %d “,stu1->sex,*((stu1)->name),(stu1)->grade);// 指针变量 stu1-> sex 这种方式和 (*stu1).sex是等效的。
}

void arrprint(Stu* stu1,int len){ //传递结构体和结构体数组都是用指针。
for(int i = 0;i

猜你喜欢

转载自blog.csdn.net/wi8ruk48/article/details/81980434