Tuesday, 17 January 2012

C - memmove

Synopsis:
#include <stdio.h>
void* memmove(void* s, const void* ct, int n); 
Description:
Copies n characters from ct to s and returns s. s will not be corrupted if objects overlap.
Return Value
The memmove function returns s after moving n characters.
Example
#include <stdio.h>
int main() {
  static char buf [] = "This is line 1 \n"
                       "This is line 2 \n"
                       "This is line 3 \n";
  printf ("buf before = %s\n", buf);
  memmove (&buf [0], &buf [16], 32);
  printf ("buf after = %s\n", buf);
  return 0;
}
It will proiduce following result:
buf before = This is line 1
This is line 2
This is line 3
buf after = This is line 2
This is line 3
This is line 3

No comments:

Post a Comment

host gator coupon