上一页 1 ··· 267 268 269 270 271 272 273 274 275 ··· 367 下一页
摘要: 1、 #include <stdio.h> int main(void) { char s[][5] = {"LISP","C","Ada"}; char *p[] = {"PAUL","X","MAC"}; int i; for(i = 0; i < 3; i++) { printf("s[%d] 阅读全文
posted @ 2021-06-02 18:00 小鲨鱼2018 阅读(47) 评论(0) 推荐(0) 编辑
摘要: 1、原始程序,数组实现的字符串和指针实现字符串的不同点 #include <stdio.h> int main(void) { char *p = "123"; printf("first p = %s\n", p); p = "456"; printf("second p = %s\n", p); 阅读全文
posted @ 2021-06-02 17:21 小鲨鱼2018 阅读(76) 评论(0) 推荐(0) 编辑
摘要: 1、strtoi #include <stdio.h> int strtoi(const char *s) { int i, j = 0; while(*s) { for(i = 0; i <= 9; i++) { if(*s - '0' == i) j = j * 10 + i; } s++; } 阅读全文
posted @ 2021-06-02 11:09 小鲨鱼2018 阅读(61) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> void del_num(char *s) //函数的形参为指针,也就是字符串数组的数组名,相当于指向数组第一个元素的指针。 { char *tmp = s; // 将指针tmp赋值为指针s,即指向传入的字符串数组的第一个元素的指针 while(*tmp) 阅读全文
posted @ 2021-06-02 08:07 小鲨鱼2018 阅读(38) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(33) 评论(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 阅读(27) 评论(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 阅读(339) 评论(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 阅读(1593) 评论(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 阅读(1696) 评论(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 阅读(235) 评论(0) 推荐(0) 编辑
上一页 1 ··· 267 268 269 270 271 272 273 274 275 ··· 367 下一页