strlen(s); 需要引用#include <cstring>文件
s.size(); 需要引用#include <string>文件
顺便一提,c++可以直接用+号连接字符串
例子如下:
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main ()
{
string s1 = "Hello";
string s2 = "World";
char s3[4]="123";
cout << s1 + s2 << endl;
cout << s2.size() <<endl;
cout << strlen(s3)<<endl;
return 0;
}