//用memset或bzero初始化结构数组
#include
#include
struct test
{
char name[20];
int age;
};
int main(int argc , char ** argv)
{
struct test s[2];
strcpy(s[0].name,"fpf");
s[0].age=20;
strcpy(s[1].name,"zhangqiang");
s[1].age=30;
//printf("name=%s,age=%d\n",s[0].name,s[0].age);
int i;
for(i=0;i<2;i++)
printf("name=%s,age=%d\n",s[i].name,s[i].age);
memset(s,0,sizeof(struct test)*2); //bzero(s,sizeof(struct test)*2);
for(i=0;i<2;i++)
printf("name=%s,age=%d\n",s[i].name,s[i].age);
return 0;
}
~
~
阅读(1685) | 评论(0) | 转发(0) |