#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
void my_memset(void *str, char n, size_t count)
{
char *dest = (char *)str;
size_t i = 0;
for (i = 0; i < count; i++)
{
*(dest + i) = n;
}
}
int main()
{
int arr[] = { 1, 2, 3, 4, 5, 6 };
my_memset(arr, 0, 16);
int i = 0;
for (; i < 6; i++)
{
printf("%d ", arr[i]);
}
system("pause");
return 0;
}
转载于:https://blog.51cto.com/10740329/1715693