c语言结构体函数



//声明结构体

struct point{

int x,y;

}


struct point make(int x,int y);


void main(){

struct point pt=make(1,2);

printf("%d%d",pt.x,pt.y);

}


struct point make(int x,iny){

struct point temp;

temp.x=x;

temp.y=y;

return temp;

}


===================================================


方法二:


typedef struct{

int x,y;

}temp;


temp make(int x, int y){

temp tp;

tp.x=x;

tp.y=y;

}


void main(){

temp tp=make(1,2);

printf("%d", tp.x)

}


原文地址:https://www.cnblogs.com/itfenqing/p/4429465.html