The output of size of for
#include<iostream>
using namespace std;
struct node
{
int k;
struct node *next;
};
int main()
{
int arr[3];
cout<<sizeof(struct node)<<endl;
cout<<sizeof(struct node *)<<endl;
cout<<sizeof(arr)<<endl;
cout<<sizeof(arr[0])<<endl;
cout<sizeof(int *)<<endl;
return 0;
}
is
8
4
12
4
4
I understand that struct node * is a pointer so its output should be 4. So similarly arr
is also a pointer, so its output should also be 4 but why is it showing the size of arr array as 12?