4 ms·
Or, not to be confused with: #include <stdio.h> #include <stdlib.h> #include <string.h> void foo(int x[5]) { printf("%p\n", x); printf("%p\
by matthavener 15y ago
Or, not to be confused with:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void foo(int x[5]) {
printf("%p\n", x);
printf("%p\n", x+1);
printf("%p\n", &x);
printf("%p\n", &x+1);
}
int main() {
int x[5];
foo(x);
return 0;
}
- bbq 15y agoTo be confused with: #include <stdio.h> void foo(int (*x)[5]) { printf("%p\n", *x); printf("%p\n", *x+1); printf("%p\n", x); printf("%p\n", x+1); } int main(void) { int x[5]; foo(&x); return 0; }
- teichman 15y agoCan you elaborate on this?
- matthavener 15y agoIn C, the array as a function parameter is different from an array as a variable/struct member. So, as a parameter, sizeof(x) is sizeof(int*). As a variable, sizeof(x) is sizeof(int[5]).