#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))吧
(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))吧
2022-09-30
在牛客打卡1天,今天学习:刷题 3 道/代码提交 9 次
全部评论
相关推荐
01-15 00:58
The University of New South Wales 数据分析师 点赞 评论 收藏
分享


腾讯
| 校招
| 超多精选岗位
点赞 评论 收藏
分享