#include <stdio.h>
#include <string.h>
struct tells;//聲明結構體
struct info
{
char *infos;
};
typedef struct Books
{
char *name;
int page;
struct info *pinfo;
struct tells *tel;
}BK;
struct tells{
char *age;
};
void pout(struct Books *b);
void pouts(struct Books *b[], int n);
int main(){
struct info str = {"信息內容描述"};
BK book1 = {"C鴛鴦",100,&str};
BK book2 = {"Java",200,&str};
BK *b = &book1;
//定義結構體數組
BK arr_book[] = {book1, book2};
//定義一個指向結構體數組的結構體指針
BK *bookp = arr_book;//數組首地址就是指針地址
int i;
for(i=0;i<2;i++){
pout(bookp+1);
printf("*******************************\n");
}
//定義結構體指針數組並初始化;里面全是結構體的地址
BK *arr_bookp[]= {b,&book2};
pouts(arr_bookp,2);
return 0;
}
void pout(BK *b){
printf("name:%s page:%d info:%s\n", b->name,b->page,b->pinfo->infos);
}
void pouts(BK *b[], int n){
printf("結構圖體指針數組大小sizeof:%ld\n",sizeof(b));
int i=0;
for(;i<n;i++){
pout(b[i]);
}
}