写了个小程序,用来给数组清零:
[root@bjxdurs235 20091108]# cat -n zero.c
1 #include
2
3 #define MAX 128
4
5 int main(void)
6 {
7 int i;
8 int size = MAX;
9 char b[MAX];
10 int a[MAX];
11 //bzero(a,64);
12 //bzero(b,64);
13 memset(a,0,MAX);
14 memset(b,0,MAX);
15
16 printf("length of a:%d\n",sizeof(a));
17 printf("length of b:%d\n",sizeof(b));
18 for(i=0; i 19 printf("a[%d]:%d ",i,a[i]);
20 printf("\n");
21 printf("\n");
22
23 for(i=0; i 24 printf("b[%d]:%d ",i,b[i]);
25 printf("\n");
26 printf("\n");
27 printf("\n");
28 b[4] = '1';
29 if(b[4]){
30 printf("ok\n");
31 }
32 else
33 {printf("no\n");}
34
35 for(i=0; i 36 printf("b[%d]:%d ",i,b[i]);
37 printf("\n");
38 printf("\n");
39
40 }
memset、bzero这两个库函数都可以给数组清零,单位都是一个byte,字节的意思,呵呵。
阅读(1001) | 评论(0) | 转发(0) |