Oops I meant division but said sizeof(). And I cannot stress this enough, my brain doesn't truncate decimal values. I never at any point said that the run-time result would be .5 I said that 4/8 = .5, they are two very distinctively different things. Even if you put:
Code:
int f(double *array) {
size_t size = sizeof(array)/sizeof(*array);
return (signed)size;
}
int main( void )
{
double array[] = { 0.0, 1.1, 2.2 };
printf("returned value is %g\n", (double)f( array ) );
return 0;
}
printf() would still print 0 due to the limitations of the data-type. I'm not certain of why you are arguing with me as I never said prelude was wrong about how the integers will be handled. However, I did say that sizeof(double *)/sizeof(double) is equal to .5. But since quzah has trouble understanding I will modify my original post:
[revision]
Code:
int f(double *array) {
size_t size = sizeof(array)/sizeof(*array);
return (signed)size;
}
Is wrong as you are saying the size of a pointer divided by the size of a double. Which on my machine would be .5, which I guarantee you is not what you were looking for Of course the return of this function will be 0 as the function is using integer math, which will truncate any decimal value.
[/revision]