这段代码错在哪里? 它不会让我投strlen(s)
为int
,我可以重复它,直到i
等于字符串的长度。strlen to int C++ - 为什么我不能这样做?
#include <iostream>
#include <string.h>
#include <string>
using namespace std;
int main()
{
string s;
cin >> s;
for (int i = 0; int n = (int)strlen(s); i < n, i++)
{
cout << s[i] << endl;
}
}
使用's.size()''strlen'为'char'阵列字符串。 – 101010
我必须更改头文件吗? –
你只需要#include'#include ' –
101010