user2985498
user2985498

Reputation: 1

Invalid conversion from char* to char?

I have a problem here

void myFunction(char string){}    

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

    myFunction(test);

}

Why does it give this error? error: invalid conversion from 'char*' to 'char' [-fpermissive]

Upvotes: 0

Views: 307

Answers (2)

Jonathan Leffler
Jonathan Leffler

Reputation: 753475

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[]);

Upvotes: 3

anjruu
anjruu

Reputation: 1264

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

Upvotes: 5

Related Questions