I am trying to find out how to find the length of an ADT array type of uint64_t in C.
The code I wrote:
char * uint64_t(char * uint64_t, const char *restrict sep);
int size = sizeof(uint64_t) / sizeof(uint64_t[0]);
printf("Size of vektor:", %zu, sizeof(uint64_t[0]));
I am not able to change any variables because it is prohibited by its creator (my professor) of whole code I can only implement some functions.
>Solution :
You cannot find the size of an array passed as a pointer into a function.
The compiler has no way of knowing how big it is, either
- pass in the length as an arg
- have a sentinel value, 0, -1, MAX_INT etc
I have ignored the fact that your code very messsed up , I assume you are trying to do this
void func(uint64_t *arr , const char *restrict sep){
int size = sizeof(arr) / sizeof(arr[0]);
printf("Size of vektor: %d", size);
}