KAIHATSUGIKEN GROUP
********************************************************************************
20 構造体のアドレス渡し
************
struct child{char name[10];int age,height:};
void past(struct child *y);
main()
{
struct child x;
sprintf(x.name,"taro");x.age=6;x.height=120;
past(&x);
}
void past(struct child *y)
{
printf("%s,%d,%d\n",y->name,y->age,y->height);
}
****
taro,6,120
****
struct child{char name[10];int age,height:};/* 構造体の型枠をグローバルで宣言*/
void past(struct child *y);
main()
{
struct child x;
sprintf(x.name,"taro");x.age=6;x.height=120;
past(&x);
}
void past(struct child *y)
{
printf("%s,%d,%d\n",y->name,y->age,y->height);
}
****
taro,6,120
****
struct child{char name[10];int age,height:};
void past(struct child *y);
main()
{
struct child x; /* 構造体変数xの宣言と値の代入 */
sprintf(x.name,"taro");x.age=6;x.height=120;
past(&x);
}
void past(struct child *y)
{
printf("%s,%d,%d\n",y->name,y->age,y->height);
}
****
taro,6,120
****
struct child{char name[10];int age,height:};
void past(struct child *y);
main()
{
struct child x;
sprintf(x.name,"taro");x.age=6;x.height=120;
past(&x); /* 関数pastを呼び出し(引き数&x) */
}
void past(struct child *y)
{
printf("%s,%d,%d\n",y->name,y->age,y->height);
}
****
taro,6,120
****
struct child{char name[10];int age,height:};
void past(struct child *y);
main()
{
struct child x;
sprintf(x.name,"taro");x.age=6;x.height=120;
past(&x);
}
void past(struct child *y) /* 構造体childのポインタ変数yで引き数を受け取り */
{
printf("%s,%d,%d\n",y->name,y->age,y->height);
}
****
taro,6,120
****
struct child{char name[10];int age,height:};
void past(struct child *y);
main()
{
struct child x;
sprintf(x.name,"taro");x.age=6;x.height=120;
past(&x);
}
void past(struct child *y) /* y=&x x.name taro,x.age=6,x.height=120 */
{
printf("%s,%d,%d\n",y->name,y->age,y->height);
}
****
taro,6,120
****
struct child{char name[10];int age,height:};
void past(struct child *y);
main()
{
struct child x;
sprintf(x.name,"taro");x.age=6;x.height=120;
past(&x);
}
void past(struct child *y)
{
printf("%s,%d,%d\n",y->name,y->age,y->height);/* yを介しx.name,x.age,x.height*/
}
****
taro,6,120
****
struct child{char name[10];int age,height:};
void past(struct child *y);
main()
{
struct child x;
sprintf(x.name,"taro");x.age=6;x.height=120;
past(&x);
}
void past(struct child *y)
{
printf("%s,%d,%d\n",y->name,y->age,y->height);
}
****
taro,6,120