CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Array Decay to Pointer

C++ code walkthrough · Question 7
hardArrays

Code

Read carefully. What does this print?
1#include <iostream>
2using namespace std;
3 
4void printSize(int arr[]) {
5 cout << sizeof(arr) << endl;
6}
7 
8int main() {
9 int arr[] = {1, 2, 3, 4, 5};
10 cout << sizeof(arr) << endl;
11 printSize(arr);
12 return 0;
13}

Your answer