- 5
- 0
- 约8.16千字
- 约 55页
- 2017-01-02 发布于未知
- 举报
C语言程序设计教程 主编 张永 胡敏 中国水利水电出版社 第5章 数组 主要内容 5.1 一维数组 5.2 多维数组 5.3 字符数组与字符串 6.测字符串长度函数strlen 格式:strlen(字符数组名) 功能:测字符串的实际长度(不含字符串结束标志\0)并作为函数返回值。 【例5-14】测出输入字符串的实际长度。 #includestdio.h #includestring.h main() { int k; char st[20]; gets(st); k=strlen(st); printf(The lenth of the string is %d\n,k); } 输入字符串: ilikefootball 输出: The lenth of the string is 13 5.3.7 字符数组应用举例 【例5-15】输入一个字符串,统计其中指定字符的数目。 #includestdio.h #includestring.h main() { int i,len,num; char a,st[50]; printf(please input the string:); gets(st); printf(please enter the c
原创力文档

文档评论(0)