瀏覽單個文章
Chief_WU
Senior Member
 
Chief_WU的大頭照
 

加入日期: Jul 2001
您的住址: 台北市
文章: 1,401
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. 不會解釋
 
舊 2003-10-14, 10:25 AM #2
回應時引用此文章
Chief_WU離線中