function parameters

André Albergaria Coelho andre1coelho@outlook.com
Tue Nov 21 02:30:47 GMT 2023


Hello

#include <stdio.h>

void func(char *ptr) {
     printf("\n%i",sizeof(ptr));
}

int main(void) {
     char arr[10];
     printf("\n Sizeof arr %i",sizeof(arr));
     func(arr);

     return 0;
}

/* sizeof(arr) != sizeof(ptr), but they point to same thing. */


So problem. On main, arr has size 10, while on func, arr has size 8. But 
they are equal.


-- 
André Albergaria Coelho
andrealbergaria@gmail.com


More information about the Gcc mailing list