#include<iostream>
using namespace std;
void* my_memcpy_byte(void* dst, const void* src, int n)
{
if (dst == NULL || src == NULL || n <= 0)
return NULL;
char* pdst = (char*)dst;
char* psrc = (char*)src;
if (pdst > psrc && pdst < psrc + n)
{
pdst = pdst + n - 1;
psrc = psrc + n - 1;
while (n--)
*pdst-- = *psrc--;
}
else
{
while (n--)
*pdst++ = *psrc++;
}
return dst;
}
int main()
{
char s[17];
int a[4];
cin >> s;
int len = strlen(s);
my_memcpy_byte(a, s, len);
cout << a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[3];
}
c++字节拷贝——指针
最新推荐文章于 2023-09-02 11:38:34 发布