Skip to content

Instantly share code, notes, and snippets.

@kelvin-fly
Created October 19, 2012 05:19
Show Gist options
  • Select an option

  • Save kelvin-fly/3916372 to your computer and use it in GitHub Desktop.

Select an option

Save kelvin-fly/3916372 to your computer and use it in GitHub Desktop.
the code is memmove
#include <stdio.h>
#include <string.h>
void *memmovea(char *dest, const char *src, size_t n);
int main()
{
char *dest , *res, *src = "abcdefg";
size_t n = 6;
dest = (char *)malloc(11*sizeof(char));
res = (char *)memmovea(dest,src,n);
puts(res);
free(dest);
return 0;
}
void *memmovea(char *dest, const char *src, size_t n)
{
int i;
char *a = dest;
for(i=0; i<n; i++, *dest++=*src++)
;
return a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment