Click here to Skip to main content
15,888,968 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
Joop Eggen29-Nov-20 23:25
Joop Eggen29-Nov-20 23:25 
GeneralRe: C declarations are half backward Pin
Rusty Bullet30-Nov-20 3:52
Rusty Bullet30-Nov-20 3:52 
GeneralRe: C declarations are half backward Pin
honey the codewitch30-Nov-20 3:55
mvahoney the codewitch30-Nov-20 3:55 
GeneralRe: C declarations are half backward Pin
Kirk 1038982130-Nov-20 4:18
Kirk 1038982130-Nov-20 4:18 
GeneralRe: C declarations are half backward Pin
honey the codewitch30-Nov-20 4:26
mvahoney the codewitch30-Nov-20 4:26 
GeneralRe: C declarations are half backward Pin
Kirk 1038982130-Nov-20 4:37
Kirk 1038982130-Nov-20 4:37 
GeneralRe: C declarations are half backward Pin
honey the codewitch30-Nov-20 4:46
mvahoney the codewitch30-Nov-20 4:46 
GeneralRe: C declarations are half backward Pin
Kirk 1038982130-Nov-20 6:37
Kirk 1038982130-Nov-20 6:37 
Ah,
therein lies the dilemma:

What does
char[] a[100], b;
declare b as?
Worse, when I read "a", it says: "a[100]" is an ELEMENT (or pointer) to an array,
Because I see it as:
char []a[100];  // where [] == *
char *a[100];
and
char[] a(100); // would make more sense, to NOT confuse the symbology to me

The * modifier and the [] modifiers are applied to the variable, not the type.

hence
char *a,**b,c[100],d; // are all fine

// And yes the [2]a was just "putting it in front, as requested"

But I feel we must "adapt" to nuances of every language. I primarily code in Delphi (Pascal based) for the last 20+ years... So I am having to THINK HARDER about C and C# syntax.

That adaptation in C is pretty low, and coding standards would say the Decoration stays with the variable, not the type! That rectifies about 80% of it to me.

Proof:
char* a,b,c;  // Does NOT declare 3 variables of the same type!
char *a,b,c; // Therefore is the proper notation
IMO...
GeneralRe: C declarations are half backward Pin
honey the codewitch30-Nov-20 6:39
mvahoney the codewitch30-Nov-20 6:39 
GeneralRe: C declarations are half backward Pin
BernardIE531730-Nov-20 5:50
BernardIE531730-Nov-20 5:50 
GeneralRe: C declarations are half backward Pin
honey the codewitch30-Nov-20 5:51
mvahoney the codewitch30-Nov-20 5:51 
GeneralRe: C declarations are half backward Pin
BernardIE531730-Nov-20 6:02
BernardIE531730-Nov-20 6:02 
GeneralRe: C declarations are half backward Pin
honey the codewitch30-Nov-20 6:04
mvahoney the codewitch30-Nov-20 6:04 
GeneralRe: C declarations are half backward Pin
BernardIE531730-Nov-20 6:22
BernardIE531730-Nov-20 6:22 
GeneralRe: C declarations are half backward Pin
honey the codewitch30-Nov-20 6:24
mvahoney the codewitch30-Nov-20 6:24 
GeneralRe: C declarations are half backward Pin
BernardIE531730-Nov-20 8:38
BernardIE531730-Nov-20 8:38 
GeneralRe: C declarations are half backward Pin
Stuart Dootson30-Nov-20 5:53
professionalStuart Dootson30-Nov-20 5:53 
GeneralRe: C declarations are half backward Pin
Stuart Dootson30-Nov-20 5:52
professionalStuart Dootson30-Nov-20 5:52 
GeneralRe: C declarations are half backward Pin
honey the codewitch30-Nov-20 5:54
mvahoney the codewitch30-Nov-20 5:54 
GeneralRe: C declarations are half backward Pin
Member 1330167930-Nov-20 8:18
Member 1330167930-Nov-20 8:18 
GeneralRe: C declarations are half backward Pin
honey the codewitch30-Nov-20 8:26
mvahoney the codewitch30-Nov-20 8:26 
GeneralRe: C declarations are half backward Pin
Member 1330167930-Nov-20 8:49
Member 1330167930-Nov-20 8:49 
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 

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.