#include <iostream>(30326)#include <string>using namespace std;int main() { char *str; char strName[50] = {0}; int lenth =0; cin.getline(strName,sizeof(strName)); str=strName; while(*str!= ) { lenth++; str++; } cout<<lenth<<endl;}C++ cin>>>如果都是string类型 那就getline(cin,str)吧如果有char这种 那就cin.getline(str,sizeof(str))吧