- #include <stdio.h>
- int main()
- {
- struct lv
- {
- char *name;
- int age;
- };
- struct lv l1={"栋1",11};
- struct lv l2={"国2",12};
- struct lv arr1[]={l1,l2}; //结构体数组
- printf("arr1[0].name=%s\tarr1[1].age=%d\n",arr1[0].name,arr1[1].age);
- //以下是改变结构体数组某个元素的值
- arr1[0].name="吕3";
- arr1[1].age=13;
- printf("arr1[0].name=%s\tarr1[1].age=%d\n",arr1[0].name,arr1[1].age);
- return 0;
- }
复制代码
|
|