-->
当前位置:首页 > 题库

函数题:字符串长度 - C/C++ 指针及引用

Luz4年前 (2022-09-06)题库597
strLength()函数用于统计指针s所指向的以0结尾的字符串的长度(字符个数),请实现该函数,使得下述程序可以正确运行。注意不能使用原生的strlen()函数。


### 函数接口定义:
c++
unsigned int strLength(const char* s);


### 裁判测试程序样例:
c++
#include <stdio.h>

//在此处定义strLength()函数

int main()
{
char s[1024];
gets(s);
printf("%d",strLength(s));
return 0;
}





### 输入样例:
in
spring festival


### 输出样例:
out
15



### 感觉不会? 那试着听听**免费的B站网课**
[简洁的C和C++ - 重庆大学在线课程](https://www.bilibili.com/video/BV1it411d7zx/)
[Python编程基础及应用 - 重庆大学在线课程](https://www.bilibili.com/video/BV1kt411R7uW/)
![image.png](~/6e79c9e3-cb7f-486d-ab78-36b5a8f655c0.png)









答案:若无答案欢迎评论