void func(char *s[]){
printf("s: %d\n", sizeof(s));
}
void caller(){
char *a[2];
for(int i = 0; i < 2; i++){
a[i] = (char *)malloc(50 * sizeof(char));
}
strcpy(a[0], "something");
strcpy(a[1], "somethingelse");
printf("a: %d\n", sizeof(a));
func(a);
}
This outputs
a: 16
s: 8
Why is the output of sizeof()
different in caller()
and func()
? Also, is it possible for func
to get the number of char *
in the array via sizeof
?