C Reference String Operation: memmove()

The function memmove() copies n characters from source to target.


void *memmove(void *target, void *source, size_t count);

Note: The copy still works if the objects overlap.

memmove() source code example:


		char line[100];
		char *ptr_my;

		strcpy(ptr_my, "aaa");

		memmove(&ptr_my[3], "bbb", 2);

		printf("%s\n", ptr_my);

Note: we give three b’s, but the count is set to 2. Make the ‘\0′ is put at the right position.

Output of the example:


This entry was posted in C Reference string.h Functions. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site. Tweet This! Tweet This! or use to share this post with others.

Leave a Reply: