Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

size of array #44

Open
BenShen98 opened this issue Mar 22, 2019 · 1 comment
Open

size of array #44

BenShen98 opened this issue Mar 22, 2019 · 1 comment

Comments

@BenShen98
Copy link

BenShen98 commented Mar 22, 2019

For an array:

int (*a[5])[3]

sizeof( *a[1][1] ) //4
sizeof( *(a[1]) ) //12

Why the above sizeof would give different result?
Because first one is dereference 3 time, and second one is dereference 2 time.

@BenShen98
Copy link
Author

found the answer here:
https://stackoverflow.com/questions/1461432/what-is-array-decaying

void by_value(const T* array)   // const T array[] means the same
void by_pointer(const T (*array)[U])
void by_reference(const T (&array)[U])

@johnwickerson , I just would like to check, the last option, void by_reference(const T (&array)[U]) is only for C++ right? we don't have pass by reference in C?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant