Skip to content

Instantly share code, notes, and snippets.

@liyang85105
Created June 12, 2014 03:05
Show Gist options
  • Save liyang85105/276b82ee67c5b77b65af to your computer and use it in GitHub Desktop.
Save liyang85105/276b82ee67c5b77b65af to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
void copy(char * to, char * from, int count)
{
int n = (count + 7 ) / 8 ;
switch (count % 8 ) {
case 0 : do { *to++ = *from++;
case 7 : *to++ = *from++;
case 6 : *to++ = *from++;
case 5 : *to++ = *from++;
case 4 : *to++ = *from++;
case 3 : *to++ = *from++;
case 2 : *to++ = *from++;
case 1 : *to++ = *from++;
} while (--n > 0);
}
}
int main(int argc, const char *argv[])
{
char from[100] = "Hello, my name is liyang. I come from city of Daqing.";
char to[100];
copy(to, from, strlen(from)+1);
printf("dest content: %s\n", to);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment