From mboxrd@z Thu Jan 1 00:00:00 1970 From: krewat@kilonet.net (Arthur Krewat) Date: Thu, 11 May 2017 18:01:36 -0400 Subject: [TUHS] C declarations. In-Reply-To: <015401d2caa0$79762650$6c6272f0$@ronnatalie.com> References: <015401d2caa0$79762650$6c6272f0$@ronnatalie.com> Message-ID: But wouldn't that imply you didn't need to use the * when referencing the actual value? For example, if you do this: char *p; char c; The correct way to get the character it's pointing to dereference like this: c=*p; If the type was char* (not char) Wouldn't that imply I wouldn't need the * to dereference the pointer? On 5/11/2017 5:49 PM, Ron Natalie wrote: > 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: > > >