#include<stdio.h>
#include<stdlib.h>
void Memmove(void* b, void* a, int bitlen)
{
char* aa = (char*)a;
char* bb = (char*)b;
if (bb >= aa && bb <= aa + bitlen)
{
aa = aa + bitlen - 1;
bb = bb + bitlen - 1;
for (int i = 0;i < bitlen;i++)
{
*bb = *aa;
aa–;
bb–;
}
}
else
{
for (int i = 0;i < bitlen;i++)
{
*bb = *aa;
bb++;
aa++;
}
}
}
int main()
{
int a[5] = { 1,2,3,4 };
Memmove(a + 1, a, 16);
for (int i = 1;i <= 4;i++)
{
printf("%d “, a[i]);
}
printf(”\n");
system(“pause”);
return 0;
}
memmove()函数的实现
最新推荐文章于 2023-09-12 18:26:45 发布