.size() 与 .length() 的返回值是无符号数。
#include <iostream>
using namespace std;
int main() {
string a = "";
cout << a.size() << ' ' << a.length() << endl;
cout << a.size() - 1 << ' ' << a.length() - 1 << endl;
return 0;
}
输出:
.size() 与 .length() 的返回值是无符号数。
#include <iostream>
using namespace std;
int main() {
string a = "";
cout << a.size() << ' ' << a.length() << endl;
cout << a.size() - 1 << ' ' << a.length() - 1 << endl;
return 0;
}
输出: