Clarification needed on Pointers/Arrays
Doug Gwyn
gwyn at smoke.BRL.MIL
Sun Feb 26 12:43:21 AEST 1989
In article <23877 at watmath.waterloo.edu> rbutterworth at watmath.waterloo.edu (Ray Butterworth) writes:
-int A[10];
-float F;
-short S;
-What is A when evaluated in an expression? a constant pointer to an int.
-What is F when evaluated in an expression? a double.
-What is S when evaluated in an expression? an int.
It all depends on the context. For example, consider sizeof(whatever).
That's why it is best not to mentally map the type until the language
rules require that it be mapped.
One of our computer vendors once decided to map array names to pointer
prematurely, so that sizeof A returned 4 no matter how big the array A
was. We screamed and they eventually fixed that bug. Let that serve
as a warning of the danger of trying to map types before their time.
More information about the Comp.lang.c
mailing list