64,282
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include "string"
using namespace std;
int main()
{
int i;
char str[100];
//string str;
cout << "请输入你的字符" << endl;
cin.getline(str, 100);
i = strlen(str);
cout << "字符串长度为" << i << endl;
system("pause");
return 0;
/*
int i;
string str;
cout << "请输入你的字符" << endl;
getline(cin,str);
i = str.length();
cout << "字符串长度为" << i << endl;
system("pause");
return 0;
*/
}