>I'm just saying that gets can find out, but it doesn't care to.
No, it can't.
Code:
#include <stdio.h>
char *foo(char *buffer)
{
printf("wrong size: %lu\n", (long unsigned)sizeof(buffer)/sizeof(*buffer));
return NULL;
}
int main(void)
{
char line[100];
printf("right size: %lu\n", (long unsigned)sizeof(line)/sizeof(*line));
foo(line);
return 0;
}
/* my output
right size: 100
wrong size: 4
*/
>So, it would'nt work if I malloc a character array dynamically, for example?
No, not there either.
[edit]
>If the array was declared to be a 100 bytes at compile time as in your example, and you CAN use sizeof(buff) / sizeof(*buff) to reliably tell you the length than why would the pointer *p in your function be any different than buff?
Because an array is not a pointer.
[/edit]