Reputation: 4109
When you see code like this in C, what's the order of assignment?
int i = 0, var1, var2;
I don't understand the syntax...
Upvotes: 3
Views: 300
Reputation: 21921
All of them are local variables , the only difference is i has been assigned a value zero whereas the values of var1 and var2 are unpredictable, they will have garbage values.
Upvotes: 0
Reputation: 92874
i
is initialized to 0
whereas variables var1
and var2
are uninitialized and thus have unspecified values(if they are defined in a local scope).
Upvotes: 4
Reputation: 300728
Only i
is assigned the value zero.
var1
and var2
are uninitialized.
Upvotes: 11
Reputation: 320671
There's no "assignment" in your code whatsoever. It is a declaration of three variables of type int
, of which one is initialized with zero. The =
symbol is an integral part of initialization syntax, it has nothing to do with any "assignment". And since there's only one initialization there, there's really no question about any "order".
If that doesn't answer your question, clarify it.
Upvotes: 7