[TUHS] C declarations.

Ron Natalie ron at ronnatalie.com
Fri May 12 07:49:31 AEST 2017


Bjarne agrees with you.   He put the * (and the &) with the type name to emphasize it is part of the type.
This works fine as long as you only use one declaration per statement.

The problem with that is that * doesn't really bind to the type name.   It binds to the variable.

char* cp1, cp2;   // cp1 is pointer to char,   cp2 is just a char.

I always found it confusing that the * is used to indicate an pointer here, where as when you want to change an lvalue to a pointer, you use &.

But if we're going to gripe about the evolution of C.   My biggest gripe is when they fixed structs to be real types, they didn't also do so for arrays.
Arrays and their  degeneration to poitners is one of the biggest annoyances in C.

> Am I the only one here who thinks that e.g. a char pointer should be
> "char* cp1, cp2" instead of "char *cp1, *cp2"?  I.e. the fundamental type is "char*", not "char", and to this day I still write:




More information about the TUHS mailing list