News for hackers. Stuff that matters.
Re:No more confusions on tricky C declarations by scott_s on Saturday June 26, 2010 @07:56PM (#1464539)
I find that problem goes away if you only declare a single variable per line. Generally, I find people who do

  int* foo;
Started with C++ and people who do

  int *foo;
Started with C. I started with C++.
Re:No more confusions on tricky C declarations by dkersten on Saturday June 26, 2010 @09:15PM (#1464648)
I have made the same observation and as someone who started with C++, I think it makes more sense that

    int* i;
is an int pointer named i.

    int *i;
just looks strange.. an int named pointer i umm?

Besides, declaring only one variable per line seems less cluttered to me, so I never get the

    int* a, b;
confusion.
Re:No more confusions on tricky C declarations by prodigal_erik on Sunday June 27, 2010 @12:20AM (#1464893)
I never put the asterisk next to the type, because I wanted to train myself the way the grammar actually works rather than the way almost everyone wished it worked.
Re:No more confusions on tricky C declarations by scott_s on Sunday June 27, 2010 @08:06AM (#1465383)
But the compiler recognizes the type of the variable as int*.
Re:No more confusions on tricky C declarations by rbonvall on Sunday June 27, 2010 @12:10AM (#1464877)
When used in an expression, I read p as "what's pointed by p". In a declaration, this applies as well:

    int *i;
means "what's pointed by i is an int".
Re:No more confusions on tricky C declarations by dkersten on Sunday June 27, 2010 @10:56AM (#1465538)
That makes more sense alright, but I still think it would make a lot more sense if * was bound to the type.