memmove dynamic memory allocation

Memmove is used to copy bytes. If the target area and the source area overlap, memmove can ensure that the source string will copy the bytes of the overlapping area to the target area before being overwritten, but the source content will be changed after copying. But when the target area does not overlap with the source area, it has the same function as the memcpy function.

#include <stdio.h>
#include <string.h>

int _tmain(int argc, _TCHAR* argv[])
{
	char s[]="Golden Global View";
	memmove(s,s+7,strlen(s)+1-7);
	printf("%s",s);
	getchar();

	return 0;
}

 Program output: Global View

 

Extension:

Dynamic memory allocation -------- "? ? ? ? ? ? ? ? ?

Guess you like

Origin www.cnblogs.com/hshy/p/12727701.html