home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!agate!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: <1beqfnINN3sr@bigboote.WPI.EDU>
- Date: 13 Oct 92 15:37:27 GMT
- Reply-To: surendar@cs.wpi.edu
- Organization: Worcester Polytechnic Institute, Worcester MA 01609, USA.
- Lines: 15
- NNTP-Posting-Host: ivy.wpi.edu
- X-Newsreader: TIN [version 1.1 PL6]
-
- I have trouble understanding this const * stuff with ANSI 'C'. I thought
- that the C compiler should flag a function like length1 as error as I
- modify str. However our gcc version 2.1 for (sparc) does not give any
- warning even for -pedantic -Wall. I tried the other way too "const char *str"
- and that is not flagged as an error. Is that supposed to be an error in ANSI C??
- int length1(char const *str)
- {
- int count = 0;
-
- while(*str++)
- count++;
- return(count);
- }
- Thanks
- surendar
-