Files
C_code/C语言/翁凯C语言/7/字符串函数strlen.c
T
Serendipity 93c16edb5a 更新MD文件路径引用
- 修正主README.md中的所有路径引用,使其与当前文件结构一致
- 更新翁凯C语言学习指南链接路径
- 更新五子棋AI项目文档链接路径
- 更新数据结构学习文档链接路径
- 修正编译说明和学习模块使用指南中的目录路径
- 改进五子棋README.md的编译运行说明,增加Windows和Linux/macOS的分平台指导
- 确保所有文档链接和路径引用都能正确工作
2025-10-17 10:52:27 +08:00

37 lines
581 B
C

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
// !字符串函数string.h
/*
1.string.h
strlen、strcmp、strcpy、strcat、strchr、strstr
2.strlen
size_t strlen(const char *s);
返回s的字符串长度(不包括结尾的0)
3.
*/
int my_strlen(const char *s)
{
int idx = 0;
while (s[idx]!='\0')
{
idx++;
}
return idx;
}
int main(void)
{
/* strlen */
char line[] = "Hello";
printf("strlen=%lu\n", strlen(line));
printf("my_strlen=%d\n", my_strlen(line));
printf("sizeof=%lu\n", sizeof(line));
return 0;
}