摘要: 1、 #include <stdio.h> void del(char *str) { while(*str) { if(*str >= '0' && *str <= '9') printf(""); else putchar(*str); str++; } } int main(void) { c 阅读全文
posted @ 2021-06-01 22:15 小鲨鱼2018 阅读(35) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> #include <ctype.h> void str_toupper(char *s) { while(*s) { *s = toupper(*s); s++; } } void str_tolower(char *s) { while(*s) { *s 阅读全文
posted @ 2021-06-01 21:44 小鲨鱼2018 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 1、c语言中转换字符串函数 atoi将字符型转换为int型。 c语言标准函数库提供了字符串转换函数。 <stdlib.h>。 #include <stdio.h> #include <stdlib.h> //c语言标准函数库 int main(void) { char str[128]; print 阅读全文
posted @ 2021-06-01 21:29 小鲨鱼2018 阅读(343) 评论(0) 推荐(0) 编辑
摘要: 1、函数原型。 #include <stdio.h> int strncmp(const char *s1, const char *s2, size_t n) //函数返回int型,形参为两个指向char型的指针)和 unsigned 型n。 { while(n && *s1 && *s2) // 阅读全文
posted @ 2021-06-01 20:15 小鲨鱼2018 阅读(1611) 评论(0) 推荐(0) 编辑
摘要: 1、函数原型。 #include <stdio.h> int strcmp(const char *s1, const char *s2) // 函数返回int型,形参为两个指向char型的指针 { while(*s1 == *s2) //当元素相等时 { if(*s1 == '\0') // 判断 阅读全文
posted @ 2021-06-01 18:31 小鲨鱼2018 阅读(1709) 评论(0) 推荐(0) 编辑
摘要: 1、函数原型 #include <stdio.h> char *strncat(char *s1, const char *s2, size_t n) //函数的返回值为指向char型的指针,形参为两个指针(函数间数组(字符串数组)的传递是以指向数组第一个元素的指针进行的)和正整数n。 { char 阅读全文
posted @ 2021-06-01 11:29 小鲨鱼2018 阅读(239) 评论(0) 推荐(0) 编辑
摘要: 1、函数原型 #include <stdio.h> char *strcat(char *s1, const char *s2) //函数返回类型为指针,形参为两个指针(为字符串数组的数组名,相当于指向数组第一个元素的指针) { char *tmp = s1; //将指针tmp赋值为s1指针,也就是 阅读全文
posted @ 2021-06-01 10:21 小鲨鱼2018 阅读(1694) 评论(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 阅读(1563) 评论(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 阅读(1542) 评论(0) 推荐(0) 编辑
摘要: 1、函数原型(利用指针求字符串的长度) #include <stdio.h> size_t strlen(const char *s) //函数头的形参为常数的、指向char型的指针,也就是接收的形参为指针(实际上传入的是字符串数组,函数间数组的传递实际上是通过指向第一个元素的指针完成的) { // 阅读全文
posted @ 2021-06-01 08:57 小鲨鱼2018 阅读(2192) 评论(0) 推荐(0) 编辑