• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Const correctness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Const correctness


  • Subject: Re: Const correctness
  • From: David Fang <email@hidden>
  • Date: Mon, 13 Jun 2005 12:30:59 -0400 (EDT)

Hi,

> IIRC "const char* cs" declares a constant pointer to a character string
> where "const char *cs" declares a pointer to a constant character string.

Almost.
	"const char* cs" == "char const* cs"
		pointer to constant chars
	"char* const cs"
		constant pointer to chars
	"char const *const cs"
		constant pointer to constant chars

> In the first case you can modify the string but not the pointer; in the
> second you can modify the pointer but not the string that it points to.

	I used to be confused about it a long time ago.  Someone
summarized in an earlier post: "const" modifies the thing to the left.  If
there's nothing to the left, then it applies to the right.

> I'm sure someone (the syntax police) will let us know if I'm smoking crack.
> ;-)

	Now you know, welcome to the police force!


David Fang

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Const correctness
      • From: Cameron Hayne <email@hidden>
References: 
 >Re: Const correctness (From: George Warner <email@hidden>)

  • Prev by Date: Re: Const correctness
  • Next by Date: Moving from CodeWarrior to XCode
  • Previous by thread: Re: Const correctness
  • Next by thread: Re: Const correctness
  • Index(es):
    • Date
    • Thread