题解 | #获取字符串长度#

获取字符串长度

https://www.nowcoder.com/practice/9a2d212d23f5436c80607d5e68c6d12a

#include <iostream>
using namespace std;

int main() {

    char str[100] = { 0 };
    cin.getline(str, sizeof(str));

    // write your code here......
    char *ptr=str;
    int i =0;
    while(*ptr!='\0')
    {
        i++;
        ptr++;
    }

    cout << i;

    return 0;
}

#获取字符串长度#
全部评论

相关推荐

双尔:你就写拥有ai开发经历,熟练运用提示词,优化ai,提高ai回答质量
点赞 评论 收藏
分享
10-21 16:54
门头沟学院 Java
后端转测开第一人:微服务没用 校招都不看微服务的 还有就是后端行情是这样的 找实习纯看运气 秋招更是吃运气和缘分 如果对代码没有极致的追求 可以转测开
应届生简历当中,HR最关...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务