C语言之字符串库函数五(memcpy)

要求:模拟实现memcpy()函数

#include
#include
#include


void* my_memcpy(void* dest, void* src, int count)
{
	void* ret = dest;
	assert(dest != NULL);
	assert(src != NULL);

	while (count--)
	{
		*(char*)dest = *(char*)src;
		((char*)dest)++;
		((char*)src)++;
	}
	return ret;
}

int main()
{
	int a[] = {1,2,3,4,5,6};
	int b[20] = {0};
	my_memcpy(b,a,24);
	for(int i = 0 ;i

你可能感兴趣的:(C语言)