#include <iostream>
using namespace std;
int main(){
char s1[] = "";
cout << sizeof(s1) << endl;
//1
char s2[] = "hello world";
cout << sizeof(s2) << endl;
//12
char *p = s2;
cout << sizeof(p) << endl;
//4
char *q = NULL;
cout << sizeof(q) << endl;
//4
void *r = malloc(100);
cout << sizeof(r) << endl;
//4
char s3[10] = {'m','o'};
cout << strlen(s3) << endl;
//2
char s4[2] = {'m','o'};
cout << strlen(s4) << endl;
//不确定
return 0;
}
sizeof&strlen
最新推荐文章于 2024-01-09 14:22:16 发布