#include <iostream>
using namespace std;
struct ENTINFO {
char ent_add[255];
};
typedef struct ENTINFO _ENTINFO;
int main(int argc, char *argv[])
{
_ENTINFO *ent_info_pointer;
_ENTINFO ent_info[1024];
memset(ent_info,0,sizeof(_ENTINFO)*1024);
strcpy(ent_info[0].ent_add,"guangdong shenzhen nanshan new haofang garden");
strcpy(ent_info[1].ent_add,"guangdong shenzhen nanshan haofang garden");
strcpy(ent_info[2].ent_add,"guangdong shenzhen nanshan haofang garden 6 floor");
ent_info_pointer = ent_info;
printf("ent_info_pointer->ent_add=%s\n",ent_info[0].ent_add);
printf("ent_info_pointer->ent_add=%s\n",ent_info[1].ent_add);
printf("ent_info_pointer->ent_add=%s\n",ent_info[2].ent_add);
printf("ent_info_pointer->ent_add=%s\n",ent_info_pointer->ent_add);
ent_info_pointer++;
printf("ent_info_pointer->ent_add=%s\n",ent_info_pointer->ent_add);
ent_info_pointer++;
printf("ent_info_pointer->ent_add=%s\n",ent_info_pointer->ent_add);
return 0;
}
using namespace std;
struct ENTINFO {
char ent_add[255];
};
typedef struct ENTINFO _ENTINFO;
int main(int argc, char *argv[])
{
_ENTINFO *ent_info_pointer;
_ENTINFO ent_info[1024];
memset(ent_info,0,sizeof(_ENTINFO)*1024);
strcpy(ent_info[0].ent_add,"guangdong shenzhen nanshan new haofang garden");
strcpy(ent_info[1].ent_add,"guangdong shenzhen nanshan haofang garden");
strcpy(ent_info[2].ent_add,"guangdong shenzhen nanshan haofang garden 6 floor");
ent_info_pointer = ent_info;
printf("ent_info_pointer->ent_add=%s\n",ent_info[0].ent_add);
printf("ent_info_pointer->ent_add=%s\n",ent_info[1].ent_add);
printf("ent_info_pointer->ent_add=%s\n",ent_info[2].ent_add);
printf("ent_info_pointer->ent_add=%s\n",ent_info_pointer->ent_add);
ent_info_pointer++;
printf("ent_info_pointer->ent_add=%s\n",ent_info_pointer->ent_add);
ent_info_pointer++;
printf("ent_info_pointer->ent_add=%s\n",ent_info_pointer->ent_add);
return 0;
}
运行结果:
ent_info_pointer->ent_add=guangdong shenzhen nanshan new haofang garden
ent_info_pointer->ent_add=guangdong shenzhen nanshan haofang garden
ent_info_pointer->ent_add=guangdong shenzhen nanshan haofang garden 6 floor
ent_info_pointer->ent_add=guangdong shenzhen nanshan new haofang garden
ent_info_pointer->ent_add=guangdong shenzhen nanshan haofang garden
ent_info_pointer->ent_add=guangdong shenzhen nanshan haofang garden 6 floor
strcture_array_test.cpp
root@17*.2*.38.78:~/c++/struct# ./a.out
No. Name sex age Score
10101Tom M 18 0
10102John M 19 0
10103Mary F 17 0
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/3910/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
最后编辑: jackxiang 编辑于2011-7-28 12:45
评论列表