1. 程式人生 > >C語言_指向結構體的指標_plusC14.4

C語言_指向結構體的指標_plusC14.4

#include<stdio.h>
#define LEN 20
struct name
{
char first[LEN];
char last[LEN];
};
struct guy
{
struct name handle;
char favfood[LEN];
char job[LEN];
double income;
};
main()
{
struct guy fellow[2]=
{
{{"qqq","www"},"eee","rrr",12.56},
{{"aaa","sss"},"ddd","fff",32.568}
};
struct guy *him;
printf("adress#1:%p\nadress#2:%p\n",&fellow[0],&fellow[1]);
him=&fellow[0];
printf("pointer #1:%p,#2:%p\n",him,him+1);
printf("him->income is $%.2f,(*him).income is $%.2f\n",him->income,(*him).income);
him++;
printf("him->favfood is %s,him->handle.last is %s\n",him->favfood,him->handle.last);
return 0;
}