测试代码:
#include <memory.h>
#include <string.h>
#include <stdio.h>
char string1[60] = "000001234567";
int main( void )
{
fprintf(stderr, "%s:%d:%s, string1=%s leosu \n",__FILE__, __LINE__,__FUNCTION__, string1 );
memcpy(&string1[0], &string1[5],7);
fprintf(stderr, "%s:%d:%s, string1=%s leosu \n",__FILE__, __LINE__,__FUNCTION__, string1 );
return 1;
}
leosu@leosu:/mnt/tmp/c_cplusplus_test$ gcc memcpy_test.cpp
leosu@leosu:/mnt/tmp/c_cplusplus_test$ ./a.out
memcpy_test.cpp:8:main, string1=000001234567 leosu
memcpy_test.cpp:10:main, string1=123456734567 leosu
来源:CSDN
作者:bamboolsu
链接:https://blog.csdn.net/bamboolsu/article/details/42969719