home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #23 / NN_1992_23.iso / spool / gnu / gcc / help / 2329 < prev    next >
Encoding:
Internet Message Format  |  1992-10-15  |  942 b 

  1. Path: sparky!uunet!stanford.edu!ames!elroy.jpl.nasa.gov!sdd.hp.com!spool.mu.edu!hri.com!noc.near.net!bigboote.WPI.EDU!surendar
  2. From: surendar@wpi.edu (Surendar C.)
  3. Newsgroups: gnu.gcc.help
  4. Subject: Constant pointers with ANSI C
  5. Message-ID: <1bk3naINNrvi@bigboote.WPI.EDU>
  6. Date: 15 Oct 92 15:45:46 GMT
  7. Reply-To: surendar@cs.wpi.edu
  8. Organization: Worcester Polytechnic Institute, Worcester MA 01609, USA.
  9. Lines: 21
  10. NNTP-Posting-Host: ivy.wpi.edu
  11. X-Newsreader: TIN [version 1.1 PL6]
  12.  
  13. Thanks to all who helped me clarify that char const * == const char *.
  14. But I still don't get why the warning is given for one line and not the other.
  15. Is the increment operator ++ any different from += 1;. I compiled this
  16. under gcc 2.1 (-ansi -pedantic)
  17.  
  18. Thanks for any help
  19. surendar
  20.  
  21. int length(const char *const str)
  22. {
  23.     int count = 0;
  24.  
  25.     while(*str)
  26.     {
  27.         str += 1; /* Get a warning here */
  28.         str++;    /* Get no warning here */
  29.         count++;
  30.     }
  31.  
  32.     return(count);
  33. }
  34.