开发者

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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜