bzero memset setmem

bzero

置字节字符串s的前n个字节为零。

 #include <syslib.h>
       #include <string.h>
       int main()
       {
                struct
                {
                      int a;
                      char s[5];
                      float f;
                } tt;
                char s[20];
                bzero(&tt,sizeof(tt));   // struct initialization to zero       bzero(s,20);
                clrscr();
                printf("Initail Success");
                getchar();
                return 0;
        }

 extern void *memset(void *buffer, int c, int count);
用法:#include <string.h>

    
功能:把buffer所指内存区域的前count个字节设置成字符c。 

 

 #include <syslib.h>
       #include <string.h>
       int main()
       {
           char *s="Golden Global View";
            clrscr();
           memset(s,'G',6);
           printf("%s",s);
           getchar();
            return 0;
        }

 

setmem  
原型:

extern void setmem(void *buf, unsigned int count, char ch);          
用法:#include <string.h>    


功能:把buf所指内存区域前count个字节设置成字符ch。    
说明:返回指向buf的指针。    
举例:       // setmem.c
       #include <syslib.h>
       #include <string.h>
       int main()
       {
            char *s="Golden Global View";
           clrscr();
           setmem(s,6,'G');
          printf("%s",s);
            getchar();
          return 0;
        }

posted @ 2012-10-28 16:32  greencolor  阅读(325)  评论(0编辑  收藏  举报