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; }

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务