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

获取字符串长度

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(),我们只需要完成下面的判断部分就好了

全部评论

相关推荐

重生我想学测开:嵌入式的问题,我准备入行京东外卖了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务