
----------字符串
文章平均质量分 53
寂寂寂寂寂蝶丶
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
字符串与字符数组的关系
实现字符串与字符数组的连接 #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { #if 0 char name[10] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g' }; for (int i = 0; i < 10; i++) { *(name + i) = 'm'; //数组可以改转载 2017-11-12 23:43:28 · 504 阅读 · 0 评论 -
字符串的大小及与指针的关系
字符串的大小及与指针的关系 #include "stdafx.h" //常见的常量 1 1.0 存储在代码段 //常见的字符串,存储在数据段中的只读数据段(RO read only) int _tmain(int argc, _TCHAR* argv[]) { int a = 1; //sizeof(a); sizeof(int); sizeof(1); printf("%d\n",转载 2017-11-12 23:33:46 · 604 阅读 · 0 评论 -
求字符数组中字符串的长度strlen(自实现)
求字符串长度方法一 #include "stdafx.h" #include //常说的字符串长度(strlen)是不包含'\0'的 int _tmain(int argc, _TCHAR* argv[]) { char name[100] = "china"; printf("%d\n", sizeof(name)); //自实现求长度 int len = 0; char*原创 2017-11-13 00:06:04 · 1929 阅读 · 0 评论 -
字符串的连接strcat(自实现)
strcat自实现的三种方法 #include "stdafx.h" #include int _tmain(int argc, _TCHAR* argv[]) { char firstName[30] = "jim"; char lastName[30] = "Green"; #if 0 方法一: char* p = firstName; char* q = lastName;原创 2017-11-13 14:23:26 · 554 阅读 · 0 评论 -
字符串的复制strcpy的使用以及自实现
strcpy的自实现 #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { char firstName[30] = "jim"; char lastName[30] = "Green"; char* p = firstName; char* q = lastName; while (1) { if (*q !原创 2017-11-13 14:26:20 · 4000 阅读 · 0 评论 -
字符串比较strcmp的自实现及应用
strcmp的自实现 #include "stdafx.h" #include int _tmain(int argc, _TCHAR* argv[]) { // strcm 本质是ascii的比较, //相等的逻辑:长度相同,字符一样,两指针同时比较后移,直到同时出现\0,退出 //不相等的逻辑:同时比较后移,如若现不等,则直接返回比较结果,即可。 char x[] = "a原创 2017-11-13 15:30:51 · 713 阅读 · 0 评论 -
存放字符串的指针数组相关应用
字符指针数组的原地排序 #include "stdafx.h" #include //冒泡法排序 void popSort(int* p, int n); int _tmain(int argc, _TCHAR* argv[]) { //char* array[10];//指针数组 放地址的(数组中的各个元素都是字符指针) char* name[] = { "IBM", "Appl转载 2017-11-13 22:57:49 · 518 阅读 · 0 评论 -
_strdup函数以及与strcpy函数的区别
_strdup函数以及与strcpy函数的区别 #include "stdafx.h" #include <iostream> using namespace std; #if 0 1._strdup函数 _strdup函数原型: char* _strdup(const char* s) { size_t len = strlen(s) + 1; void* new = ...原创 2018-08-16 14:23:58 · 727 阅读 · 0 评论