上一页 1 ··· 302 303 304 305 306 307 308 309 310 ··· 403 下一页
摘要: 1、函数原型 #include <stdio.h> int strcmp(const char *s1, const char *s2) { while(*s1 == *s2) { if(*s2 == '\0') return 0; s1++; s2++; } return (unsigned ch 阅读全文
posted @ 2021-06-03 10:45 小鲨鱼2018 阅读(1662) 评论(0) 推荐(0)
摘要: 1、函数原型 #include <stdio.h> char *strncat(char *s1, const char *s2, size_t n) { char *tmp = s1; while(*s1) s1++; while(n--) { if(!(*s1++ = *s2++)) break 阅读全文
posted @ 2021-06-03 10:04 小鲨鱼2018 阅读(225) 评论(0) 推荐(0)
摘要: 1、函数原型 #include <stdio.h> char *strcat(char *s1, const char *s2) { char *tmp = s1; while(*s1) s1++; while(*s1++ = *s2++) ; return tmp; } int main(void 阅读全文
posted @ 2021-06-03 09:49 小鲨鱼2018 阅读(1348) 评论(0) 推荐(0)
摘要: 1、函数原型 #include <stdio.h> char *strncpy(char *s1, const char *s2, size_t n) { char *tmp = s1; while(n) { if(!(*s1++ = *s2++)) //此处是if语句,不能用while、for等, 阅读全文
posted @ 2021-06-02 23:19 小鲨鱼2018 阅读(285) 评论(0) 推荐(0)
摘要: 1、函数原型。 #include <stdio.h> char *strcpy(char *s1, const char *s2) { char *t = s1; while(*s1++ = *s2++) ; return t; } int main(void) { char str1[128] = 阅读全文
posted @ 2021-06-02 22:28 小鲨鱼2018 阅读(1770) 评论(0) 推荐(0)
摘要: 1、 #include <stdio.h> char *mach(char *s, int key) { while(*s) { if(*s == key) return s; s++; } return NULL; } int main(void) { char str[128]; printf( 阅读全文
posted @ 2021-06-02 21:45 小鲨鱼2018 阅读(51) 评论(0) 推荐(0)
摘要: 1、 #include <stdio.h> int count(const char *s, int key) { int j = 0; while(*s) { if(*s == key) j++; s++; } return j; } int main(void) { char str[128]; 阅读全文
posted @ 2021-06-02 21:35 小鲨鱼2018 阅读(52) 评论(0) 推荐(0)
摘要: 1、 #include <stdio.h> void put(const char *s) { while(*s) putchar(*s++); putchar('\n'); } int main(void) { char str[128]; printf("str: "); scanf("%s", 阅读全文
posted @ 2021-06-02 21:30 小鲨鱼2018 阅读(49) 评论(0) 推荐(0)
摘要: 1、利用数组下标运算符 #include <stdio.h> int len(char s[]) { int len = 0; while(s[len]) len++; return len; } int main(void) { char str[128]; printf("str: "); sc 阅读全文
posted @ 2021-06-02 21:22 小鲨鱼2018 阅读(1212) 评论(0) 推荐(0)
摘要: 1、 #include <stdio.h> char *copy(char *d, const char *s) { char *t = d; while(*d++ = *s++) ; return t; } int main(void) { char str1[] = "abcd"; char s 阅读全文
posted @ 2021-06-02 20:02 小鲨鱼2018 阅读(45) 评论(0) 推荐(0)
上一页 1 ··· 302 303 304 305 306 307 308 309 310 ··· 403 下一页