0

我这里有问题

void myFunction(char string){}    

int main(void)
{
    char test[] = "HEYYY";

    myFunction(test);

}

为什么会出现此错误?error: invalid conversion from 'char*' to 'char' [-fpermissive]

4

2 回答 2

5

Because myFunction takes in a character, not a cstring. What do you want myFunction to do? Did you mean void myFunction(const char *string) { }?

于 2013-11-14T17:49:23.417 回答
3

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[]);
于 2013-11-14T17:49:35.290 回答