comma operators problem in function call
http://c-faq.com/expr/comma.html
FAQ say
...but the commas separating the arguments in a function call are not comma operators....
What are they then??
They're just argument separators. Nothing magical going on here.
(If for some reason you did want to invoke the comma operator within a parameter list of a function call, use an extra pair of parentheses around the things to be comma-operator'd.)
(If for some reason you did want to invoke the comma operator within a parameter list of a function call, use an extra pair of parentheses around the things to be comma-operator'd.)
Quote:Original post by Zahlman
They're just argument separators. Nothing magical going on here.
(If for some reason you did want to invoke the comma operator within a parameter list of a function call, use an extra pair of parentheses around the things to be comma-operator'd.)
For clarity of code sake, however, such juicy syntax is probably best avoided. [wink]
It's actually an important point to remmember though. It means that the following is undefined:
func(i++,i)
Whereas this is fine:
myVar=(i++,i)//same as myVar=++i
func(i++,i)
Whereas this is fine:
myVar=(i++,i)//same as myVar=++i
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement