3 ms·
Ah, 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 th
by natesm 15y ago
Ah, 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.