home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / amiga / programm / 15896 < prev    next >
Encoding:
Text File  |  1992-11-16  |  1.3 KB  |  38 lines

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