自定义strlen()
来源:互联网 发布:血源诅咒帅哥捏脸数据 编辑:程序博客网 时间:2024/06/15 21:17
自定义strlen()
源代码
/* * 自定义strlen()函数 * */#include <stdio.h>#include <assert.h>#include <string.h>int my_strlen(const char *str){ int count = 0; assert(NULL != str); while (*str++ != '\0') count++; return count;}int main(void){ char str[] = "hello world"; char *ptr = NULL; printf(" strlen(str) : %d\n", (int)strlen(str)); printf("my_strlen(str) : %d\n", my_strlen(str)); printf("my_strlen(ptr) : %d\n", my_strlen(ptr)); return 0;}
运行结果
[root@localhost lwp_workspace]# ./test strlen(str) : 11my_strlen(str) : 11test: my_strlen.c:14: my_strlen: Assertion `((void *)0) != str' failed.已放弃[root@localhost lwp_workspace]#
0 0
- 自定义strlen()
- 自定义实现strlen
- 自定义字符串长度计算Strlen()
- 自定义字符串函数:strlen,strcat,strcpy,strcmp
- 自定义字符串函数:strlen,strcat,strcpy,strcmp
- strlen
- strlen()
- strlen
- strlen
- strlen
- strlen
- strlen
- strlen
- strlen
- strlen
- strlen
- strlen
- strlen()
- 基于TensorFlow的MNIST(手写图像识别)的一点经验
- 计算机图形学01——坐标系
- 机器学习 数据预处理之独热编码(One-Hot Encoding)
- 解决端口号占用
- Recyclerview条目可拖拽可侧滑删除实战详解
- 自定义strlen()
- 1023.组个最小数
- getResponseCode获取URL响应状态码
- Leetcode-标签为Tree 108. Convert Sorted Array to Binary Search Tree
- 使用Qt带的MinGW+cmake编译opencv3.2
- 函数数据传递
- No Suitable Driver Found For Jdbc_我的解决方法
- Euclidean Geometry(数学)
- Minimum Number of Arrows to Burst Balloons