#include <stdio.h> #include <stdlib.h> #include <limits.h> #include <time.h> #include <pthread.h> #include <semaphore.h> #include <unistd.h> #include <signal.h> #include <string.h> #include <stdlib.h> // 一个苹果 二个苹果 3个苹果 struct _fruit { char name[125]; int size; int color; char* region; int price; }; typedef struct _fruit fruit_t; static fruit_t applet[100] = { { .size = 100, .region = "shenzhen", .price = 5, }, { .size = 100, .region = "guangzhan", .price = 10, }, { .size = 100, .region = "guangzhan", .price = 2, }, { .size = 100, .region = "guangzhan", .price = 4, }, { .size = 100, .region = "guangzhan", .price = 10, }, }; int main() { fruit_t*p = applet; // 结构体指针访问结构体数组 printf("size is %d ",p[0].size); printf("color is %d ",p[0].color); printf("price is %d ",p[4].price); for(;;); return 0; }