Has this syntax for accessing an array EVER been legal?
k, a friend of mine swears that in a class an instructor told him that this was legal. Now this class was years ago (he's a 35 year old programmer/manager), so what I'm wondering if maybe in years gone past or in some early phase of C was this syntax EVER legal.
int bla[10];
[3]bla = 1;
Obviously the brackets are being placed before the variable, I said it hasn't, a few friends also have said the same thing, but he wants more proof. So any of you guys out there (and hopefully some oldies) can give me some proof that this have never been legal I would appreciate it.
Thanks,
Chris Olson
Re: Has this syntax for accessing an array EVER been legal?
Quote:
Originally posted by Colson33
k, a friend of mine swears that in a class an instructor told him that this was legal. Now this class was years ago (he's a 35 year old programmer/manager), so what I'm wondering if maybe in years gone past or in some early phase of C was this syntax EVER legal.
int bla[10];
[3]bla = 1;
Obviously the brackets are being placed before the variable, I said it hasn't, a few friends also have said the same thing, but he wants more proof. So any of you guys out there (and hopefully some oldies) can give me some proof that this have never been legal I would appreciate it.
Thanks,
Chris Olson
Yes, it's legal, but only used in obsfuscation contests.
The reason is that bla[10] is equivalent to *(bla + 10). [10]bla is equivalent to *(10 + bla). Same thing.
Regards,
Paul Mckenzie