Created
June 12, 2014 03:05
-
-
Save liyang85105/276b82ee67c5b77b65af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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