home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!caen!uvaarpa!adastra!mbs
- From: mbs@adastra.cvl.va.us (Michael B. Smith)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: What is wrong with this very simple c program?
- Distribution: world
- Message-ID: <mbs.1bkm@adastra.cvl.va.us>
- References: <BxIpyB.E7@unx.sas.com> <johnv.03kr@acix.DIALix.oz.au>
- X-NewsSoftware: GRn-beta 1.16g (11.15.92) by Michael B. Smith & Mike Schwartz
- Date: 16 Nov 92 06:42:32 EDT
- Organization: Well, I haven't decided on a name yet...
- Lines: 25
-
- In article <johnv.03kr@acix.DIALix.oz.au> johnv@acix.DIALix.oz.au (John Verhoeven) writes:
- > James Cooper (jamie@cdevil.unx.sas.com) wrote:
- > > C doesn't have any protection mechanism to see if you go outside the
- > > boundaries of an array. You have to check for this yourself.
- >
- > Whats even more fun :-) is that in some compilers accessing arrays with
- > a negative subscript is also legal, eg foo[-1] = 5.
- >
- > Does SAS C V6 allow this ?
-
- If it doesn't, it's broken.
-
- This construct is very useful, especially when using it with pointers.
- For example:
-
- char *p;
-
- ...
- p[-1] = '\0';
- ...
-
- I use it when building up arrays of null-terminated strings quite a bit..
- --
- // Michael B. Smith
- \X/ mbs@adastra.cvl.va.us -or- uunet.uu.net!virginia.edu!adastra!mbs
-