Possible Duplicate:
sizeof array of structs in C?
sizeof an array passed as function argument
Just trying to write a basic sum()
function.
int sum(int arr[]) {
int total = 0 , i = 0 , l = sizeof arr;
for(i=0;i<l;i++) {
total += arr[i];
}
return total;
}
l
always equates to 4 (I know to eventually divide it by sizeof int
)
Running Dev-C++ with default compiler options in Windows 7.