查询数组长度
C++中查询数组长度可以使用_countof宏
需要引用头文件stdlib.h
具体方法如下:
1 #include2 using namespace std; 3 #include ; //引用stdlib.h头文件 4 5 int main() 6 { 7 8 int Arr_1[5] = { 1,2,3,5,4 }; 9 10 cout << _countof(Arr_1) << endl; //查询数组长度 11 12 13 system("pause"); 14 return 0; 15 }