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

获取字符串长度

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

#include <iostream>
#include <stdio.h>

using namespace std;

int main() {

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

    // write your code here......

    char* pc = str;
    int count = 0;
    while(*pc != '\0')
    {
        count++;
        pc = pc + 1;
    }
    printf("%d", count);

    return 0;
}

这里给出了输入函数cin.getline(),我们只需要完成下面的判断部分就好了

全部评论

相关推荐

点赞 评论 收藏
分享
MinJerous:虽然我一直说 计算机不怎么卡学历 但是至少得一本
点赞 评论 收藏
分享
Beeee0927:是缅甸园区吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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