代码编译不出来,warning: invalid conversion from `char*' to `char'
#include<stdio.h>#include<string.h>
char hanshu(char *string,char ch);
int main()
{
char b='h',a[50];
gets(a);
printf("%c",*hanshu(a,b));
}
char hanshu(char *string,char ch)
{
while(*(string++)!='\0')
if(*string==ch)
{
return string;
break;
}
}
如上代码,编译信息如下:
g++.exe -x c++ -c E:\编程\c文件\ggggg -o E:\编程\c文件\ggggg.o -Wall -fpermissive -Wno-sign-compare -g
E:\编程\c文件\ggggg: In function `int main()':
E:\编程\c文件\ggggg:8: error: invalid type argument of `unary *'
E:\编程\c文件\ggggg: In function `char hanshu(char*, char)':
E:\编程\c文件\ggggg:15: warning: invalid conversion from `char*' to `char'
Failure
谢谢