我这里有问题
void myFunction(char string){}
int main(void)
{
char test[] = "HEYYY";
myFunction(test);
}
为什么会出现此错误?error: invalid conversion from 'char*' to 'char' [-fpermissive]
我这里有问题
void myFunction(char string){}
int main(void)
{
char test[] = "HEYYY";
myFunction(test);
}
为什么会出现此错误?error: invalid conversion from 'char*' to 'char' [-fpermissive]
Because myFunction
takes in a character, not a cstring. What do you want myFunction
to do? Did you mean void myFunction(const char *string) { }
?
Your function is, apparently, expecting a single character in a parameter (mis)named string
.
You probably need to fix the prototype (definition):
void myFunction(char *string);
void myFunction(char string[]);