题解 | #获取字符串长度#
获取字符串长度
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(),我们只需要完成下面的判断部分就好了