3 ms·
But then you write int* foo, bar; and the troubles begin...
by drv 15y ago
But then you write
int* foo, bar;
and the troubles begin...
- natesm 15y agoAh, that's exactly the thing I try to avoid. Presumably you're going to use those variables, right? So, unless there's truly an issue (conditional assignment that is too complex for a ternary) why not declare them at the point of use? C99 lets us do that, there's no reason to keep the C89 habits. Meaning: int* foo = whatever; // do some stuff with foo, now we need bar int* bar = whatever; Outside of a for loop, I would never do two assignments on the same line, so it isn't an issue. If it really has to be done like that, I just suck it up in that case. C has its warts.
- sp332 15y agoBut it still looks cleaner to put your variables first and your code after. It's like in a play, you mention which characters are going to be in the scene before you get to the dialogue.
- sp332 15y agoYes, this has bitten me recently and it's almost enough to make me type it the other way. Almost...