Assign single value to multiple variables
I want to开发者_开发问答 assign 0 to all declared values in a single statement.
char r, g, b = 0;
The above only assigns 0 to b but not to the other variables
You can do it two ways:
char r = 0, g = 0, b = 0;
or
char r, g, b;
r = g = b = 0;
Tersest form is:
int r,g,b=g=r=0;
精彩评论