+ 1

C++ - Sizeof() strikes again

In the following code, I understand n1 is 9, but WHY n2 is 2? int mas[9] = {2, 6, 3, 9, 1, 0, 5, 8, 4}; int* p = new int[9]; for(int i = 0; i < 9; ++i){ p[i] = mas[i]; } int n1 = sizeof(mas)/sizeof(*mas); int n2 = sizeof(p)/sizeof(*p); cout << n1 << n2;

19th Sep 2019, 1:13 PM
Paolo De Nictolis
Paolo De Nictolis - avatar
1 Odpowiedź