题解 | 获取字符串长度
#include <iostream> using namespace std; int main() { char str[100] = { 0 }; cin.getline(str, sizeof(str)); // write your code here...... int count = 0; char* ptr = str; while (*ptr != '\0' && ptr < str + 100) { count ++; ptr ++; } cout << count << endl; return 0; }