#include<iostream>
using namespace std;
int main(){
char test1[] = "";
cout<<sizeof(test1)<<endl; // 1
cout<<strlen(test1)<<endl; // 0
int test2[] = {1, 2, 3};
cout<<sizeof(test2)/sizeof(int)<<endl; // 3
// strlen只能用于char s[]
}
C++中的sizeof和strlen
最新推荐文章于 2024-06-07 20:33:34 发布