I am not new to C++, but today I found that the size of the array is different in the main function and in other functions. Why is that? I suppose it's something related to pointers.
#include<bits/stdc++.h>
using namespace std;
void func(int arr[]){
cout<<"func size: "<<sizeof(arr)<<"\n";
}
int main(){
int arr[5];
cout<<sizeof(arr)<<"\n";
func(arr);
return 0;
}
You can test this code to see the difference.