C memmove()

The memmove() function copies count characters from the array pointed to by from into the array pointed to by to. If arrays overlap, the copy will take place correctly, placing the correct contents into to but leaving from modified.

The memmove() function returns a pointer to to.

memmove() Syntax

Following is the syntax of the memmove() function :

void *memmove(void *to, const void *from, size_t count);

memmove() Example

Following program shifts the content of the str down 10 places and displays the result :


#define SIZE 80

void main()
	char str[SIZE], *p;
	strcpy(str, "When, in the course of...");
	p = str + 10;
	memmove(str, p, SIZE);
	printf("result after shift: %s", str);

C Online Test

« Previous Chapter Next Function »

Like/Share Us on Facebook 😋