Sign in to follow this  
Japanese

comma operators problem in function call

Recommended Posts

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??

Share this post


Link to post
Share on other sites
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.)

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this