#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
using namespace std;
int main(void) {
char a[5] = { 'a','b','c','d'};
cout << "a: " << sizeof(a) << " " << strlen(a) << endl;
string b = "abcd";
cout << "b: " << b.size() << " " << b.length() << endl;
system("pause");
}
输出:
a: 5 5
b: 4 4