strlen()函数返回给定字符串的长度。它不计算空字符"\0"。
#include<stdio.h>#include<string.h> int main(){ char ch[20]={'L', 'e', 'a', 'r', 'n', 'f', 'k', 'c', 'o', 'm', '\0'}; printf("Length of string is: %d",strlen(ch)); return 0; }
输出:
链接:https://www.learnfk.comhttps://www.learnfk.com/c-programming/c-strlen.html
来源:LearnFk无涯教程网
Length of string is: 10
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)