C++ - Sizeof() strikes again | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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
0 Answers