home *** CD-ROM | disk | FTP | other *** search
- 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
- From: surendar@wpi.edu (Surendar C.)
- Newsgroups: gnu.gcc.help
- Subject: Constant pointers with ANSI C
- Message-ID: <1bk3naINNrvi@bigboote.WPI.EDU>
- Date: 15 Oct 92 15:45:46 GMT
- Reply-To: surendar@cs.wpi.edu
- Organization: Worcester Polytechnic Institute, Worcester MA 01609, USA.
- Lines: 21
- NNTP-Posting-Host: ivy.wpi.edu
- X-Newsreader: TIN [version 1.1 PL6]
-
- Thanks to all who helped me clarify that char const * == const char *.
- But I still don't get why the warning is given for one line and not the other.
- Is the increment operator ++ any different from += 1;. I compiled this
- under gcc 2.1 (-ansi -pedantic)
-
- Thanks for any help
- surendar
-
- int length(const char *const str)
- {
- int count = 0;
-
- while(*str)
- {
- str += 1; /* Get a warning here */
- str++; /* Get no warning here */
- count++;
- }
-
- return(count);
- }
-