codescracker


c

C memmove()



« Previous Chapter Next Function »


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 :

#include<string.h>
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 :

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

#define SIZE 80

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

« Previous Chapter Next Function »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test