Click here to Skip to main content
15,889,216 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: C declarations are half backward Pin
harold aptroot30-Nov-20 9:50
harold aptroot30-Nov-20 9:50 
GeneralRe: C declarations are half backward Pin
honey the codewitch30-Nov-20 10:10
mvahoney the codewitch30-Nov-20 10:10 
GeneralRe: C declarations are half backward Pin
BernardIE531730-Nov-20 21:46
BernardIE531730-Nov-20 21:46 
GeneralRe: C declarations are half backward Pin
harold aptroot1-Dec-20 1:33
harold aptroot1-Dec-20 1:33 
GeneralRe: C declarations are half backward Pin
BernardIE53171-Dec-20 7:30
BernardIE53171-Dec-20 7:30 
GeneralRe: C declarations are half backward Pin
Julie77730-Nov-20 13:36
Julie77730-Nov-20 13:36 
GeneralRe: C declarations are half backward Pin
BernardIE531730-Nov-20 22:41
BernardIE531730-Nov-20 22:41 
GeneralRe: C declarations are half backward Pin
mike@codeproject3-Dec-20 17:44
mike@codeproject3-Dec-20 17:44 
C declarations are fine. The problem is in C pointer expressions, where two unfortunate changes were made. First, Ritchie (I presume) chose to make * the pointer dereference operator and either chose or had forced upon him by the * choice the need to make it a *left* unary operator. Had he followed Wirth's prior example in Pascal (using p^ to dereference p), then your backwards issue is automatically solved.

Why? Because C declarators are based on how the variable is used in an expression. So int *p; has the * first because you use *p in an expression to make use of the pointer. The array dimension come after the variable name: int a[5]; because you use a[index] in an expression to access a member of an array.

If the pointer dereference was on the right, then you wouldn't need the quirky -> operator that only exists to cut down on parentheses, where p->member exists only to avoid typing (*p).member.

By the way, the declaration should be "char *p;" instead of the awful "char* p;" that revisionists like to type. The * says that p is a pointer, not that "char" is a pointer. To see the difference, try using:

int* p1, p2; /* this will NOT declare two integer pointers! */

The correct syntax is:

int *p1, *p1;

...since the * says that what's on the right is a pointer.

Again, this misunderstanding wouldn't even come up with a right-unary dereference operator.

Most of the C language is admirable, particularly as a product of the early '70s, but this (along with allowing the <string.h> and parts of <stdio.h> libraries to become de facto standards) get my votes for Dennis Ritchie's biggest mistakes.
GeneralDo you know / trust this site? Pin
Nelek28-Nov-20 5:28
protectorNelek28-Nov-20 5:28 
GeneralRe: Do you know / trust this site? Pin
OriginalGriff28-Nov-20 6:25
mveOriginalGriff28-Nov-20 6:25 
GeneralRe: Do you know / trust this site? Pin
Nelek28-Nov-20 10:02
protectorNelek28-Nov-20 10:02 
GeneralRe: Do you know / trust this site? Pin
OriginalGriff28-Nov-20 10:15
mveOriginalGriff28-Nov-20 10:15 
GeneralRe: Do you know / trust this site? Pin
dandy7228-Nov-20 11:19
dandy7228-Nov-20 11:19 
GeneralRe: Do you know / trust this site? Pin
OriginalGriff28-Nov-20 11:33
mveOriginalGriff28-Nov-20 11:33 
GeneralRe: Do you know / trust this site? Pin
dandy7229-Nov-20 2:53
dandy7229-Nov-20 2:53 
GeneralRe: Do you know / trust this site? Pin
RedDk28-Nov-20 6:50
RedDk28-Nov-20 6:50 
GeneralRe: Do you know / trust this site? Pin
Cp-Coder28-Nov-20 7:24
Cp-Coder28-Nov-20 7:24 
GeneralRe: Do you know / trust this site? Pin
Nelek28-Nov-20 10:01
protectorNelek28-Nov-20 10:01 
GeneralThe Thrill of 520kB of RAM Pin
honey the codewitch28-Nov-20 2:13
mvahoney the codewitch28-Nov-20 2:13 
GeneralRe: The Thrill of 520kB of RAM Pin
Ron Anders28-Nov-20 3:03
Ron Anders28-Nov-20 3:03 
GeneralRe: The Thrill of 520kB of RAM Pin
honey the codewitch28-Nov-20 3:09
mvahoney the codewitch28-Nov-20 3:09 
GeneralRe: The Thrill of 520kB of RAM Pin
Ron Anders28-Nov-20 3:12
Ron Anders28-Nov-20 3:12 
GeneralRe: The Thrill of 520kB of RAM Pin
honey the codewitch28-Nov-20 3:15
mvahoney the codewitch28-Nov-20 3:15 
GeneralRe: The Thrill of 520kB of RAM Pin
RickZeeland28-Nov-20 3:05
mveRickZeeland28-Nov-20 3:05 
GeneralRe: The Thrill of 520kB of RAM Pin
honey the codewitch28-Nov-20 3:09
mvahoney the codewitch28-Nov-20 3:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.