c语言入门,为什么会出现错误'strcmp' : cannot convert parameter 2 from 'bool' to 'const char *'
#include<stdio.h>#include<stdlib.h>#include<string.h>structPerson{charname[10];intcou...
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct Person
{
char name[10];
int count;
}leader[3] = { "li",0,"zhang",0,"sun",0 };
int main()
{
int i, j;
char leader_n[20];
for (i = 0; i<5; i++)
{
scanf_s("%s", leader_n);
for (j = 0; j<3; j++)
{
if (strcmp(leader[j].name, leader_n == 0)//这里出错了
{
leader[j].count++;
}
}
}
printf("\nresult:\n");
for (i = 0; i<3; i++)
{
printf("%5s:%d\n", leader[i].name, leader[i].count);
}
return 0;
} 展开
#include<stdlib.h>
#include<string.h>
struct Person
{
char name[10];
int count;
}leader[3] = { "li",0,"zhang",0,"sun",0 };
int main()
{
int i, j;
char leader_n[20];
for (i = 0; i<5; i++)
{
scanf_s("%s", leader_n);
for (j = 0; j<3; j++)
{
if (strcmp(leader[j].name, leader_n == 0)//这里出错了
{
leader[j].count++;
}
}
}
printf("\nresult:\n");
for (i = 0; i<3; i++)
{
printf("%5s:%d\n", leader[i].name, leader[i].count);
}
return 0;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询