gpt4 book ai didi

在 C 中使用 if 语句的编译器警告

转载 作者:太空宇宙 更新时间:2023-11-04 05:53:29 25 4
gpt4 key购买 nike

<分区>

我正在尝试将用户输入与字符串进行比较,每次编译时,它都会给我这个警告:

warning: null argument where non-null required (argument 2)

此警告出现在每个“if”语句中。我不知道它是否会影响实际结果,但我真的很想知道如何摆脱它。这是有问题的代码:

void AddBorder(unsigned char R[WIDTH][HEIGHT], unsigned char G[WIDTH][HEIGHT], unsigned char B[WIDTH][HEIGHT],
char color[SLEN], int border_width)
{
int x,y,a=0,b=0,c=0;
printf("Enter border width:");
scanf("%d", &border_width);
printf("Availble border colors: black, white, red, green, blue, yellow, cyan, pink, orange.\n");
printf("Select border color from the options:");
scanf("%s", color);

if (strcmp(color, "black" == 0))
{
a=0;
b=0;
c=0;
}

if (strcmp(color, "pink" == 0))
{
a=255;
b=192;
c=203;
}
if (strcmp(color, "white" == 0))
{
a=255;
b=255;
c=255;
}

for (y=0; y<HEIGHT; y++)
{
for (x=0; x<WIDTH; x++)
{
R[x][y]=0;
G[x][y]=0;
B[x][y]=0;
}
}
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com