getline应用char
字符的个数
https://www.nowcoder.com/practice/dc28f2bf113a4058be888a5875206238?tpId=225&tqId=2367960&ru=/exam/oj&qru=/ta/primary-grammar-cpp/question-ranking&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3D%25E8%25AF%25AD%25E6%25B3%2595%25E7%25AF%2587%26topicId%3D225
#include #include using namespace std;
int main() { char *str; char strName[50] = {0}; int lenth =0; cin.getline(strName,sizeof(strName)); str=strName; while(*str!='\0') { lenth++; str++; } cout<<lenth<<endl; }
阿里云工作强度 665人发布
查看20道真题和解析