If ...
int a,b; is equivalent to int a; int b;
then
int a=3,2; should be equivalent to int a=3;int a=2;
I am confused ..can some one tell me what is wrong there
If ...
int a,b; is equivalent to int a; int b;
then
int a=3,2; should be equivalent to int a=3;int a=2;
I am confused ..can some one tell me what is wrong there
Did you try to compile it to see what you get?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Yes ..i tried to compile it ..It says " Declaration syntax error in function main"
The reason being is that a comma is not an operator.
Try this:
Code:int a=3, b=2;
comma is an operator, but compiler does not understands, that you here want an comma operator and misinterprets it as a delimiter of declaration list as in int a, b;
so if you want to force compiler to use comma as operator - use () as in:
int a = (2,3);
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler