如何将结构复合文字作为参数传递给函数?
这是struct我拥有的:
typedef struct
{
float r, g, b;
} color_t;
我想将 this 的复合文字struct作为参数传递给函数,如下所示:
void printcolor(color_t c)
{
printf("color is : %f %f %fn", c.r, c.g, c.b);
}
printcolor({1.0f, 0.6f, 0.8f});
但是,这给了我一个错误:
错误:'{' 标记前的预期表达式