上一页 1 ··· 268 269 270 271 272 273 274 275 276 ··· 367 下一页
摘要: 1、函数原型 #include <stdio.h> char *strcat(char *s1, const char *s2) //函数返回类型为指针,形参为两个指针(为字符串数组的数组名,相当于指向数组第一个元素的指针) { char *tmp = s1; //将指针tmp赋值为s1指针,也就是 阅读全文
posted @ 2021-06-01 10:21 小鲨鱼2018 阅读(1686) 评论(0) 推荐(0) 编辑
摘要: 1、函数原型。 #include <stdio.h> char *strncpy(char *s1, const char *s2, size_t n) //函数的返回值为指针,形参为两个指针(字符串数组,相当于指向第一个字符的指针)和n(赋值字符个数)。 { char *tmp = s1; //将 阅读全文
posted @ 2021-06-01 09:49 小鲨鱼2018 阅读(1531) 评论(0) 推荐(0) 编辑
摘要: 1、函数原型(字符串的复制) #include <stdio.h> char *strcpy(char *s1, const char *s2) //函数的返回值为指向char型的指针, 形参为指向char型的指针 { char *tmp = s1; // 将指针tmp声明为s1,s1为传入的字符串 阅读全文
posted @ 2021-06-01 09:21 小鲨鱼2018 阅读(1532) 评论(0) 推荐(0) 编辑
摘要: 1、函数原型(利用指针求字符串的长度) #include <stdio.h> size_t strlen(const char *s) //函数头的形参为常数的、指向char型的指针,也就是接收的形参为指针(实际上传入的是字符串数组,函数间数组的传递实际上是通过指向第一个元素的指针完成的) { // 阅读全文
posted @ 2021-06-01 08:57 小鲨鱼2018 阅读(2153) 评论(0) 推荐(0) 编辑
摘要: 1、函数原型。 #include <stdio.h> char *strncat(char *s1, const char *s2, size_t n) // 这里的cat指的是:concatenate { char *tmp = s1; while(*s1) s1++; while(n--) if 阅读全文
posted @ 2021-05-31 22:59 小鲨鱼2018 阅读(410) 评论(0) 推荐(0) 编辑
摘要: c语言中strcat函数。 1、函数原型。 #include <stdio.h> char *strcat(char *s1, const char *s2) { char *tmp = s1; while(*s1) s1++; while(*s1++ = *s2++) ; return tmp; 阅读全文
posted @ 2021-05-31 22:26 小鲨鱼2018 阅读(772) 评论(0) 推荐(0) 编辑
摘要: 1、函数原型。 #include <stdio.h> char *strncpy(char *s1, const char *s2, size_t n) { char *tmp = s1; while(n) { if(!(*s1++ = *s2++)) break; n--; } while(n-- 阅读全文
posted @ 2021-05-31 21:52 小鲨鱼2018 阅读(637) 评论(0) 推荐(0) 编辑
摘要: c语言中字符串的复制。 1、自定义函数 #include <stdio.h> char *str_copy(char *d, char *s) { char *t = d; while(*d++ = *s++) ; return t; } int main(void) { char str[128] 阅读全文
posted @ 2021-05-31 21:08 小鲨鱼2018 阅读(1024) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> char *str_chr(char *x, int key) { while(*x) { if(*x == key) { char *t = x; return t; } x++; } return NULL; } int main(void) { ch 阅读全文
posted @ 2021-05-31 20:09 小鲨鱼2018 阅读(44) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> int str_c(const char *x, int key) { int j = 0; while(*x) { if(*x == key) j++; x++; } return j; } int main(void) { char str[128]; 阅读全文
posted @ 2021-05-31 19:24 小鲨鱼2018 阅读(36) 评论(0) 推荐(0) 编辑
上一页 1 ··· 268 269 270 271 272 273 274 275 276 ··· 367 下一页