[gameprogrammer] Re: A Note on C Programming Style
- From: Bob Pendleton <bob@xxxxxxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Fri, 06 May 2005 14:13:05 -0500
On Thu, 2005-05-05 at 13:52 -0700, Alan Wolfe wrote:
> Wes you are the only person that i have talked to that sees the value
> of char *p instead of char* p.
>
> my hat is off to you (:
Take a look at the declaration syntax for a pointer to a function that
takes a character pointer as an argument and returns a character
pointer. :-)
No matter what else you want to say about this subject, it is the case
that variable declaration syntax in C/C++ is poorly designed. The "best"
way to declare a variable is the one that is most likely to be
understood by people reading the code.
Bob Pendleton
>
> On 5/5/05, Wes Wannemacher <techgeek@xxxxxxxxx> wrote:
> > On 5/5/05, Chris Nystrom <cnystrom@xxxxxxxxx> wrote:
> > > Hi,
> > >=3D20
> > > Here is a small rant on C programming style from my blog, that some
> > > beginners might find useful:
> > >=3D20
> > [snip]
> > >=3D20
> > > For this reason, I believe it would be better to write pointer definiti=
> on=3D
> > s:
> > >=3D20
> > > char* p;
> > >=3D20
> > > Note that the space is now between the * and the pointer name, and
> > > also that the change has no effect on the code itself.
> > >=3D20
> > [/snip]
> >=20
> > Although you make a valid point here, there is one thing that I think
> > needs to be noted about this type of notation... It can be misleading
> > if you are declaring multiple variables. For instance:
> >=20
> > char* p, q;
> >=20
> > Would mean, one pointer of type char and one char variable. I know
> > that it would be bad style to declare these two as such, but when you
> > put the * close to the type, I can see it leading to this type of
> > error later. That's normally why I put the * by the variable name
> > rather than the variable type.
> >=20
> >=20
> > ---------------------
> > To unsubscribe go to http://gameprogrammer.com/mailinglist.html
> >=20
> >
>
>
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
>
>
>
--
+--------------------------------------+
+ Bob Pendleton: writer and programmer +
+ email: Bob@xxxxxxxxxxxxx +
+ web: www.GameProgrammer.com +
+ www.Wise2Food.com +
+ nutrient info on 6,000+ common foods +
+--------------------------------------+
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- References:
- [gameprogrammer] A Note on C Programming Style
- From: Chris Nystrom
- [gameprogrammer] Re: A Note on C Programming Style
- From: Wes Wannemacher
- [gameprogrammer] Re: A Note on C Programming Style
- From: Alan Wolfe
Other related posts:
- » [gameprogrammer] A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- » [gameprogrammer] Re: A Note on C Programming Style
- [gameprogrammer] A Note on C Programming Style
- From: Chris Nystrom
- [gameprogrammer] Re: A Note on C Programming Style
- From: Wes Wannemacher
- [gameprogrammer] Re: A Note on C Programming Style
- From: Alan Wolfe