假設有一個陣列宣告如下:
int a[]= {5,4,3,7,6,5,9,8,3,4,2,1,5,3,5,7,8,1,3,4,3,2,6,7,9,6,6,9,0,4,5,6,5,1,7,8,7,9,6,0,2,5,6,7,9,3,4,0,9,8,6,1};
試運用 sizeof() 函式,求出該陣列的成員數量。- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int a[]= {5,4,3,7,6,5,9,8,3,4,2,1,5,3,5,7,8,1,3,4,3,2,6,7,9,6,6,9,0,4,5,6,5,1,7,8,7,9,6,0,2,5,6,7,9,3,4,0,9,8,6,1};
- cout<<sizeof(a)/sizeof(int)<<endl;
- system("pause");
- return 0;
- }
複製代碼 |