?

Log in

No account? Create an account
Pop quiz: what happens when you try to write beyond the end of an… - 'Twas brillig, and the slithy toves did gyre and gimble in the wabe — LiveJournal [entries|archive|friends|userinfo]
Thomas

[ website | Beware the Jabberwock... ]
[ deviantArt | the-boggyb ]
[ FanFiction | Torkell ]
[ Tumblr | torkellr ]

Links
[Random links| BBC news | Vulture Central | Slashdot | Dangerous Prototypes | LWN | Raspberry Pi]
[Fellow blogs| a Half Empty Glass | the Broken Cube | The Music Jungle | Please remove your feet | A letter from home]
[Other haunts| Un4seen Developments | Jazz 2 Online | EmuTalk.net | Feng's shui]

[Wednesday 17th May 2006 at 12:07 pm]
Thomas

boggyb
Pop quiz: what happens when you try to write beyond the end of an array?

Well, in Java the runtime quite rightly throws an ArrayIndexOutOfBoundsException.
In VB 6, assuming you've not disabled array bounds checks you'll get an error rasied.
In C, it'll happily let you scribble over whatever was after the array. Which in this case happened to be the loop variables. No prizes for guessing what happens when i is set to 0 in a loop that goes "for (i=0;i<foo;i++)"...
Link | Previous Entry | Share | Next Entry[ Penny for your thoughts? ]