I want to assign 0 to all declared values in a single statement.
我想在一个语句中为所有声明的值赋值0。
char r, g, b = 0;
The above only assigns 0 to b but not to the other variables
以上仅指定0到b但不指定其他变量
2 个解决方案
#1
22
You can do it two ways:
你可以用两种方式做到:
char r = 0, g = 0, b = 0;
or
要么
char r, g, b;
r = g = b = 0;
#2
11
Tersest form is:
Tersest表格是:
int r,g,b=g=r=0;
#1
22
You can do it two ways:
你可以用两种方式做到:
char r = 0, g = 0, b = 0;
or
要么
char r, g, b;
r = g = b = 0;
#2
11
Tersest form is:
Tersest表格是:
int r,g,b=g=r=0;