c - How to get char array size in this case? -
i'm doubt: how size of char array in case:
#include<stdio.h> void f(char * x) { printf("size %d\n", sizeof(x)/sizeof(char)); } main() { char x[5] = {'a', 'e', 'i', 'o', 'u'}; f(&x[0]); }
contrary expectations, i'm receiving 8 rather 5 or 6. wrong here?
thanks!
sizeof(x)
in code return size of pointer char *x
, not size of char array x
pointing on
and size of pointer in 64-bits system 8. , 32-bits system size of pointer 4
Comments
Post a Comment