33,311
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str = "String";
cout<<"The size of String is "<<str.size()<<endl;
cout<<"The length of String is "<<str.length()<<endl;
return 0;
}
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
string str("ABCDEFGHIJKLMNOP");
cout << str.size() << str << endl;
str[5] = '\0';
cout << str.size() << str << endl;
cout << strlen(str.c_str()) << str.c_str() << endl;
return 0;
}