您的位置:首页 > 编程语言 > C语言/C++

【C语言】【笔试题】模拟实现memset

2015-11-22 17:04 429 查看
#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;
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息