c语⾔-遍历结构体⾥的数组元素---@颜麓遍历结构体⾥的数组元素的三种⽅法 //设计⼀个描述商品的结构体,存放⼀个商品信息,并显⽰
落红不是无情
物化作
春泥更护花赏析
#include<stdio.h>struct goods
{
char name[10];//10
int date;//4
硅谷杂志
char quality[10];//10 float price;//4
};
struct goods str[5]={
{"yanlu ",20201211,"514years",100},
{"achang",20201210,"309years",99},
{"jibo ",20201209,"823years",200},
{"nailiu",20201209,"823years",99},
同性婚姻};
int main()
{
struct goods *p;
折射率float max;
int i;
printf("name date quality price\n");
09ggg
/
/第⼀种
for(p=str;p<str+4;p++)
{
printf("\n%s %d %s %.2f\n",p->name, p->date, p->quality, p->price);
}交流网
//第⼆种
//p=str;
//for (i=0;i<5;i++)
//{
// printf("\n%s %d %s %.2f\n",p->name, p->date, p->quality, p->price);
// p++;
/
/}
//第三种
//for(i=0;i<4;i++)
//{
// printf("\n%s%d%s%2.f\n",str[i].name,str[i].date,str[i].quality,str[i].price);
//}
}