Making a C array size function. This is typically the standard convention for a C array size, and it works within the function in which the array was created, but it doesn't seem to work when put into another function. Why is this?
int size(char a[]) {
    return (int) (size_t) (sizeof(a)/ sizeof(char));
}
void test() {
    char a[] = {'a','b','c','d'};
    printf("%d\n", size(a));
    printf("%d\n", (int) (size_t) (sizeof(a)/ sizeof(char)));
}
int main() {
    test();
    return 0;
}
RESULT:
8       -> INCORRECT
4       -> CORRECT
 
    