编写一个标准strlen函数
来源:互联网 发布:java wait 和await 编辑:程序博客网 时间:2024/05/16 12:05
1、代码如下:
int MyStrlen(const char *strSrc)
{
assert(strSrc != NULL);
if
(strSrc == NULL)
{
return
0;
}
int i = 0;
while
(*strSrc++ !=
'\0'
)
{
i++;
}
return
i;
}
2、VS2010下的原版函数:
/****strlen - return the length of a null-terminated string**Purpose:* Finds the length in bytes of the given string, not including* the final null character.**Entry:* const char * str - string whose length is to be computed**Exit:* length of the string "str", exclusive of the final null byte**Exceptions:********************************************************************************/size_t __cdecl strlen ( const char * str ){ const char *eos = str; while( *eos++ ) ; return( eos - str - 1 );}
3、另外,可以看看:编写一个标准strcpy函数
0 0
- 编写一个标准strlen函数
- 编写一个strlen函数,不使用变量
- 编写一个标准strcpy函数
- 编写strlen函数
- strlen 函数的编写
- strlen函数编写
- 编写一个strlen函数(不用全局变量或局部变量)
- 面试题:编写一个memcpy函数、一个strcpy函数和一个strlen函数
- strlen()函数自己编写!
- 遇到的一个面试题:编写一个strlen函数,不能使用全局变量或者局部变量
- 编写实现字符串处理函数----strlen函数
- 编写一个标准strcpy函数 等C++问题
- C 标准库 strlen 函数的实现
- 14.深层次,自己编写一个strcpy ,strlen
- 不使用库函数编写strlen函数
- 运用递归编写strlen函数实例
- C语言编写strcpy和strlen函数
- 一个简单函数strlen的逆向
- ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: N O) 解决方案
- Linux 跨服务器 复制文件 scp
- duilib各种布局的作用,相对布局与绝对布局的的意义与用法
- hive学习 hive基本功
- VC++动态链接库(DLL)编程深入浅出
- 编写一个标准strlen函数
- Java Drp项目实战—— 环境搭建
- Web性能优化方案
- Sum Root to Leaf Numbers leetcode
- LeetCode刷题笔录Word Search
- 设计模式之命令模式
- <转载>notepad++ 关联tpl文件,并且高亮显示
- PBS 命令
- string、stringbuilder、stringBuffer的区别