CJCoding With Joseph
15per day
← Back to Question List
C++ Code Walkthrough #7

Array Decay to Pointer

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