Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1021724
  • 博文数量: 297
  • 博客积分: 11721
  • 博客等级: 上将
  • 技术积分: 3431
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-25 10:21
文章分类

全部博文(297)

文章存档

2016年(9)

2011年(71)

2010年(137)

2009年(80)

分类:

2009-11-05 14:51:44

//用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;
}
~                                                                                                                                              
~            
阅读(1635) | 评论(0) | 转发(0) |
0

上一篇:学习笔记(一)

下一篇:给fpos_t赋值问题.

给主人留下些什么吧!~~