c语言结构体数组引用

 1 struct dangdang
 2 {
 3     char email[30];
 4     char name[30];
 5     char addr[100];
 6     int num;
 7     int bugnum;
 8     char tel[20];
 9     char phone[20];
10     double RMB;
11     
12 }dbdd[2]={{"[email protected]","lj","重庆市",34,77,"18778654634","4334564",1000},
13 {"[email protected]","fd","贵阳",43,65,"543475634","45345",54444}
14 };//初始化
15 void main()
16 {
17     char str[50];
18     int i;
19     int num = sizeof(dbdd)/sizeof(struct dangdang);
20     scanf("%s",str);
21     printf("你要查找的是%s",str);
22     
23     for(i=0;i)
24     {
25         if(strcmp(str,dbdd[i].phone)==0)
26         {
27             printf("找到,邮件为%s,姓名为%s,地址为%s",dbdd[i].email,dbdd[i].name,dbdd[i].addr);
28         }
29     }
30     system("pause");
31 }

 

转载于:https://www.cnblogs.com/lanjianhappy/p/6011520.html

你可能感兴趣的:(c语言结构体数组引用)