strcpy:
strcmp:
strchr:
在linux的函数库中这几个函数写法如下:
strcpy:
char *strcpy(char *dest, const char *src) { char *tmp = dest;
while ((*dest++ = *src++) != '\0') /* nothing */; return tmp; }
|
strcmp:
int strcmp(const char *cs, const char *ct) { signed char __res;
while (1) { if ((__res = *cs - *ct++) != 0 || !*cs++) break; } return __res; }
|
strchr:
char *strchr(const char *s, int c) { for (; *s != (char)c; ++s) if (*s == '\0') return NULL; return (char *)s; }
|
个人建议:在笔试面试中,最好在函数中加个出错判断,如assert(S == NULL )
阅读(855) | 评论(0) | 转发(0) |