🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #494

Constant pointers with ANSI C

#494
From: Surendar C.
Date: Thu, 15 Oct 1992 15:45
21 lines
975 bytes
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);
}
Technical Details
Message-ID: <1bk3naINNrvi@bigboote.WPI.EDU>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!ames!elroy.jpl.nasa.gov!sdd.hp.com!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!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]