- //结构体数组
- //是个数组,里面的元素是结构体
- #include <stdio.h>
- int main(){
- // 定义
- struct Person{
- char *name;
- int age;
- };
- struct Person per1={"CAT",2};
- struct Person per2={"DOG",5};
- struct Person arr[2]={per1,per2};
-
- printf("%s%d\n",arr[0].name,arr[0].age);
- return 0;
- }
复制代码 |
|