|
Senior Member
|
1. 假設
int x[5];
cout << sizeof(x[0]) << endl; // output is 4 because size of an integer is 4 bytes
cout << sizeof(x) << end; // output is 4 * 5 = 20 bytes. 4 bytes per each int element and total has 5 elements
SO
cout << sizeof(x) / sizeof(x[0]) << endl; //prints 5 (elements) because of 20 / 4
2. 不會解釋
|