Re:Modern Pascal is still in the race (2022)
by mikewarot on Thursday October 12, 2023 @05:36AM
(#37855117)
>This declares foo as a pointer to char, and bar as a char:
char* foo, bar;
So that's why I've had so many problems understanding C. I come from the Pascal world, where a type specification is straightforward.
Re:Modern Pascal is still in the race (2022)
by mikepurvis on Thursday October 12, 2023 @10:10AM
(#37857412)
On the other hand, for those of us who agree with the GP on this, one way around the pitfall is to have your project's style guide ban multiple declarations on a single line, or at least ban them for non-trivial variables— so `int x, y, z;` is permitted, but nothing more than that.
This declares two pointers to char:
This declares foo as a pointer to char, and bar as a char: We have created a trompe l'oeil by separating the * from the declarator to which it begins and attaching it to the specifier to which it doesn't.