I am new to C and I want to implement the 99 Haskell problems in C.
So far I realized that sizeof
in my last
-function prints 4
because the pointer has a length of 4.
But how can I get the size of my list in a function?
Code
#include <stdio.h>
int last(int *list){
int size = sizeof(*list);
printf("%d\n", size);
return 0;
}
int main(){
int *a = {10, 20, 30, 40, 50, 60, 70, 80, 90};
last(&a);
return 0;
}