输入5个字符串,用strcmp()函数进行比较,输出最大的字符串.

#include<stdio.h>
#include<string.h>
int main()
{
char a[5],max;
int i;
for(i=0;i<5;i++)
{
scanf("%s",a[i]);
}
for(i=1;i<5;i++)
{
if(strcmp(a[i],max)>0)
{
max=a[i];
}
}
printf("%s",max);
return 0;
}
这是我写的代码,为什老提示我
C:\Users\pro\Desktop\gfdsresg\fdsg.cpp(13) : error C2664: 'strcmp' : cannot convert parameter 2 from 'char' to 'const char *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
执行 cl.exe 时出错.

char a[5],max;

改成:
char a[5][100], *max;追问

我想知道为什么

追答

char a[5],max;

这样定义,max, a[i]是个字符,不是字符串!!

温馨提示:答案为网友推荐,仅供参考