标签:des style blog class code java
1 char * strcat(char * dest, const char * src) { 2 assert(dest != NULL && src != NULL); 3 char * p = dest; 4 while (*p) 5 p++; 6 while (*p++ = *src++); 7 return dest; 8 } 9 10 int strlen(const char * src) { 11 int count = 0; 12 while (*src++) 13 count++; 14 return count; 15 } 16 17 char * strcpy(char * dest, const char * src) { 18 assert(dest != NULL && src != NULL); 19 char * p = dest; 20 while (*p++ = *src++); 21 return dest; 22 }
其中要注意:
1 while(*p++); // P最后指向‘\0’的下一位置 2 while (*p) p++; // p最后指向‘\0‘
strcat strcpy strlen,布布扣,bubuko.com
标签:des style blog class code java
原文地址:http://www.cnblogs.com/aoun/p/3724335.html