上一页 1 ··· 269 270 271 272 273 274 275 276 277 ··· 367 下一页
摘要: 1、 #include <stdio.h> void put_string(const char *s) // 传入的实参为指针,在数组中,指向首个字符的指针的行为和数组本身一样。 { printf("%s\n", s); // 显示数组本身。 } int main(void) { char str 阅读全文
posted @ 2021-05-31 16:50 小鲨鱼2018 阅读(62) 评论(0) 推荐(0) 编辑
摘要: 1、利用数组。 #include <stdio.h> int len(char x[]) { int len = 0; while(x[len]) len++; return len; } int main(void) { char str[128]; printf("str = "); scanf 阅读全文
posted @ 2021-05-31 16:41 小鲨鱼2018 阅读(467) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> char* copy_str(char *d, const char *s) { char *t = d; while(*d++ = *s++) ; return t; } int main(void) { char str[128] = "ABCD"; 阅读全文
posted @ 2021-05-31 16:15 小鲨鱼2018 阅读(66) 评论(0) 推荐(0) 编辑
摘要: c语言中字符串的复制。 1、 #include <stdio.h> char* str_copy(char *d, const char *s) //函数的返回值为指向char型的指针型, 形参为两个指向char型的指针。 { char *t = d; // 指针t等于指针d,指针d为指向字符串第一 阅读全文
posted @ 2021-05-31 16:02 小鲨鱼2018 阅读(808) 评论(0) 推荐(0) 编辑
摘要: c语言中利用数组、指针实现字符串、字符串数组。 1、字符串 #include <stdio.h> int main(void) { char x[] = "abcd"; //数组实现字符串 ,x一般解释为指向数组第一个元素的指针 char *y = "xyz"; //指针实现字符串 ,y为指向一个字 阅读全文
posted @ 2021-05-31 11:13 小鲨鱼2018 阅读(637) 评论(0) 推荐(0) 编辑
摘要: c语言中显示字符串数组的长度(数组实现的字符串数组和指针实现的字符串数组) 1、 #include <stdio.h> int main(void) { char x[][128] = {"aaa","bb","cccccc","d","eee"}; char *y[] = {"11111","22 阅读全文
posted @ 2021-05-31 11:01 小鲨鱼2018 阅读(744) 评论(0) 推荐(0) 编辑
摘要: c语言中判断字符串的长度,利用数组和利用指针。 1、利用数组。 #include <stdio.h> int len(const char x[]) { int len = 0; while(x[len]) len++; return len; } int main(void) { char str 阅读全文
posted @ 2021-05-31 10:55 小鲨鱼2018 阅读(1694) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> int main(void) { int i; char a[][5] = {"LISP","C","Ada"}; char *p[] = {"PAUL","X","MAC"}; printf("sizeof(a) = %u\n", sizeof(a)); 阅读全文
posted @ 2021-05-31 09:39 小鲨鱼2018 阅读(59) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> int main(void) { int i; char a[][5] = {"LISP","C","Ada"}; char *p[] = {"PAUL","X","MAC"}; int j = 0; while(1) { int k = 0; while 阅读全文
posted @ 2021-05-30 23:33 小鲨鱼2018 阅读(42) 评论(0) 推荐(0) 编辑
摘要: 1、 #include <stdio.h> int main(void) { char *p = "123"; printf("p = %s\n", p); p = "456"; printf("p = %s\n", p); return 0; } ↓ #include <stdio.h> int 阅读全文
posted @ 2021-05-30 22:12 小鲨鱼2018 阅读(37) 评论(0) 推荐(0) 编辑
上一页 1 ··· 269 270 271 272 273 274 275 276 277 ··· 367 下一页