[OCLUG-devel] sizeof an array of pointers

Dan Stromberg strombrg at dcs.nac.uci.edu
Mon Jun 20 11:26:43 PDT 2005


On Mon, 2005-06-20 at 10:50 -0700, Dan Stromberg wrote:

>         printf("Number of elements in the array is %d\n", (&foo[N] - &foo[0])+1);

Doh!  Should be N-1, not N - I don't want to think about what a
particularly fussy compiler+runtime would do with a reference to the N
+1th element of an N element array.  :)  Probably fine most of the time,
but likely not guaranteed.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://localhost.localdomain/pipermail/oclug-devel/attachments/20050620/4d2356de/attachment.bin 


More information about the OCLUG-devel mailing list