Go Back   PACEDev Forums
Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read

Blogs From The Members of PACEDev Forums
Random featured blog entry from Chris
Chris's Avatar

C: sizeof(array-1)

Posted 5th December 2007 at 11:44 AM by Chris
Wonder what happens when you try to take sizeof on a fixed length array with an offset? Me too!

Quote:
int foo[12];
printf("sizeof(foo): %d\n", sizeof(foo));
printf("sizeof(foo-1): %d\n", sizeof(foo-1));
Returns:
Quote:
sizeof(foo): 48
sizeof(foo-1): 4
Peculiar!

When we try:
Quote:
printf("&foo: %p\n", &foo);
printf("&(foo-1): %p\n", &(foo-1));
...
Posted in Software
Comments 0 Trackbacks 0
Recent Entries
Recent Comments
    There are no recent entries to display.
    There are no recent comments to display.
Find more...

All times are GMT. The time now is 05:46 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.