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

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