标签:c语言 模拟实现memset
#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; }
标签:c语言 模拟实现memset
原文地址:http://10740329.blog.51cto.com/10730329/1715693