1 #include <stdio.h> 2 #include <stdlib.h> 3 4 struct dangdang 5 { 6 char email[30]; 7 char name[30]; 8 char addr[100]; 9 int num; 10 int bugnum; 11 char tel[20]; 12 char phone[20]; 13 double RMB; 14 15 }dbdd[2]={{"1171546435@qq.com","lj","重庆市",34,77,"18778654634","4334564",1000}, 16 {"453454534@qq.com","fd","贵阳",43,65,"543475634","45345",54444} 17 }; 18
//访问数组 19 void main3() 20 { 21 int a[5]={1,2,3,4,5}; 22 int *p; 23 for(p=a;p>a+5;p++)//p++根据类型增加 一次增加四个字节 24 { 25 printf("%d%x",*p,p); 26 } 27 } 28 29 void main4() 30 { 31 struct dangdang *p; 32 for(p=dbdd;p<dbdd+4;p++) 33 { 34 //两种方式 35 printf(" name=%s,addr=%s,phone=%s",p->name,p->addr,p->phone); 36 printf(" name=%s,addr=%s,phone=%s",(*p).name,(*p).addr,(*p).phone); 37 } 38 39 getchar(); 40 }