Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C Moderated > negative array ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 9 Topic 898 of 1145
Post > Topic >>

negative array index?

by "s5n" <stephan@[EMAIL PROTECTED] > Feb 19, 2007 at 04:40 PM

Hello, all!

i've seen the following construct in several pieces of C code, and i
can't for the life of me figure out (A) what it is and (B) why it is
legal:

.... myarray[-1] ...

Can someone please explain to me what it means to have a negative
array index?

Example snippets, taken from the SpiderMonkey source code:

stephan@[EMAIL PROTECTED]
> grep -e '\[-1' *.*

js.c:        value[-1] = '=';
....
jsstr.c:    argv[-1] = STRING_TO_JSVAL(str);


If someone could explain this phenomenon to me i could certainly sleep
better at night.

:)
-- 
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
 -- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
 




 9 Posts in Topic:
negative array index?
"s5n" <steph  2007-02-19 16:40:37 
Re: negative array index?
Kenneth Brody <kenbrod  2007-02-22 07:49:29 
Re: negative array index?
"Clark S. Cox III&qu  2007-02-22 07:49:36 
Re: negative array index?
Andrei Voropaev <avoro  2007-02-22 07:49:43 
Re: negative array index?
Markus Moll <markus.mo  2007-02-22 07:49:48 
Re: negative array index?
=?ISO-8859-1?Q?Hans-Bernh  2007-02-22 07:49:52 
Re: negative array index?
"Douglas A. Gwyn&quo  2007-02-22 07:49:54 
Re: negative array index?
Jack Klein <jackklein@  2007-02-22 07:50:05 
Re: negative array index?
"s5n" <steph  2007-02-25 09:13:25 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Sep 4 23:54:00 CDT 2008.