Friday, March 5, 2010

sizeof hurts me!

I should be sent back to cs101 (introduction to c programming) for writing shit like this recently:


int matrix[] = { 1, 3, 7, 11};
int i;
for (i=0; i < sizeof(matrix); i++)
{
blah...blah...blah...;
}


My instinct tells me the "sizeof" above will return more than 4 but there a voice in me that says "nah, the compiler will sort it out". Wrong! *dope slap*

Somewhere along my programming trip, I thought I remember that sizeof is a smart function! Sort of like the pointer incremental operator... you know, how it will move to the correct memory location depending on the type... Oh well, I must be mixing c up with Pascal or something... too many programs and yet still too long to go before I'm asleep.

No comments:

Post a Comment