Is it legal to pass an assignment statement to a function?
Ex:
void f(int a, int b);
int main (void)
{
int c = 2, d = 3;
f(c=d*2, d = 3);
}
void f(int a, int b)
{
return a*b;
}
My compiler is all messed up so I can't test it right now.
Is it legal to pass an assignment statement to a function?
Ex:
void f(int a, int b);
int main (void)
{
int c = 2, d = 3;
f(c=d*2, d = 3);
}
void f(int a, int b)
{
return a*b;
}
My compiler is all messed up so I can't test it right now.
Even if you can I would not recommended unless you are trying to compete in the obsfucated code constest.
zMan
Here's what I found out. I would do it like this...Originally posted by Unregistered
Is it legal to pass an assignment statement to a function?
Ex:
My compiler is all messed up so I can't test it right now.Code:void f(int a, int b); int main (void) { int c = 2, d = 3; f(c=d*2, d = 3); } void f(int a, int b) { return a*b; }
f( d*2, 3 )
But, if you insist on doing that, the first paramter a would receive (c = d * 2) which would be 12. Also, it would take d = 3 as the second, which would be 3. So I don't think you would get your desired results that way.
it would be the same thing and would definitely work.