我很難將值分配給我的全局結構(像素[3])。我已經嘗試了很多與typedef不同的組合,但仍然無法弄清楚。我想要三個類型爲flag_struct的像素結構。這個頂部是我的全局部分和函數原型: 的#include 的#includeC全局結構錯誤。難以分配值
struct flag_struct
{
int r;
int g;
int b;
}pixel[3];
bool checkInputs(int argc, int countryCode, int width);
int computeHeight(int width, int countryCode);
void printFlag(int width, int height, int countryCode, struct flag_struct pixel[]);
void make_pixel (int r, int g, int b);
void flagColor(int width, int height, int countryCode);
這是我的代碼是給我的錯誤像素...每個錯誤狀態的[]每行的功能:錯誤:表達式之前的期望表達式。
void flagColor(int width, int height, int countryCode)
{
if (countryCode == 1)
pixel[] = 0,85,164, 255,255,255,250,60,50;
else if (countryCode == 2)
pixel[] = 0,0,0, 255,0,0, 255,204,0;
else if (countryCode == 3)
pixel[] = 253,185,19, 0,106,68, 193,39,45;
printFlag(width, height, countryCode, pixel);
return;
}
任何幫助都將不勝感激!