一、memset
#include<stdio.h> #include<stdlib.h> #include<memory.h> void *mymemset(void *p, int num, int len) { char *px = (char *)p; if (p == NULL) return NULL; while (len>0) { *px = (char)num; px++; len--; } return p;//因为上述代码是对px进行操作,p的地址没有变化,所以最后返回p } void main() { char str[40]= {"china is great"}; int num[5] = { 1,2,3,4,5 }; float f[5] = { 1.0,2.0,3.0,4.0,5.0 }; //memset(str, ' ', 40); mymemset(str, '