3 ms·
Usually declare variables one per line, so, type is still clear when: char* var1; char var2;
by jjesus 10y ago
Usually declare variables one per line, so, type is still clear when:
char* var1;
char var2;
- pawadu 10y agoC does not in anyway forbid having two definitions on the same line hence char var2, *var1; is valid C while in Java this would be illegal char var2, [] var1; So the syntax is correct and all you are doing is to add style rules that make it less readable.
- shakna 10y agoHaving one var per line, with left bound typing seems more readable to me. That said, I understand the differences in traditions. I think that C's syntax is flexible that we can each go to our own, and decide which is more readable.
- delinka 10y agoI tend to see typedef on a pointer type to address this. typedef char * pchar; pchar var1, var2; // Now they're both pointers I'm not really a fan, but it can address the problem.
- crpatino 10y agoThe language is that of Redmont, which I shall not utter here.
- bonzini 10y agoAnd then leave the poor beginner wondering why it's char var1[10]; and not char[10] var1; The rule is simple once you understand it, variables are declared with the same syntax that is used to access it later.