我初始化了一個大小爲10的數組,但是在打印sizof數組時顯示了40。代碼如下,Sizeof(Array)打印錯誤值
#include <iostream>
using namespace std;
int main() {
int arr[10] = {2,4,5,6,7,8,9,6,90};
printf("%d \n" , sizeof(arr));
}
輸出:
/Users/venkat/Library/Caches/CLion2016.1/cmake/generated/InsertionSort-e101b03d/e101b03d/Debug/InsertionSort
40
Process finished with exit code 0
什麼ç打印40在這裏?
使用'的printf( 「%つ\ n」 個,的sizeof(ARR)/的sizeof(ARR [0]);''% d'用於'int' –
[請參閱此處的C文檔。](http://port70.net/~nsz/c/c11/n1570.html#6.5.3.4) – alk
'using namespace std;'is無效的標準C代碼 – chux