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;
        }

原文地址:https://www.cnblogs.com/greencolor/p/2743707.html