🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #485

Constant pointers with ANSI C

#485
From: Surendar C.
Date: Tue, 13 Oct 1992 15:37
15 lines
968 bytes
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
Technical Details
Message-ID: <1beqfnINN3sr@bigboote.WPI.EDU>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!spool.mu.edu!hri.com!noc.near.net!bigboote.WPI.EDU!surendar

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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]