struct val{
int first;
int second;
};
int maxChainLen(struct val p[],int n);
int main() {
int t;
cin>>t;
while(t--) {
int n;
cin>>n;
val p[n];
for(int i=0;i<n;i++) {
cin>>p[i].first>>p[i].second;
}
cout<<maxChainLen(p,n);
}
return 0;
}
int maxChainLen(struct val p[],int n){
int x=sizeof(p);
cout<<x<<endl;
return 0;
}
Input
1
5
5 24 39 60 15 28 27 40 50 90
Here I am simply finding the sizeof of array p inside maxChainLen() method, which ideally should be 5*size of p[0], ie- 5*8 = 40bytes.
But sizeof(p) and sizeof(p[0]) both are displaying 8.
I know this is very basic but I have no idea why sizeof() is giving wrong results here.