0

What does this error mean and how can I solve it?
"argument of type 'const char*' is incompatible with parameter of type char*'"

I have this C++ method defined as:

void output(int x, int y, char*string)  

and I'm trying to call it like this:

output(-11, 6, "Top");
Itamar Kerbel
  • 2,508
  • 1
  • 22
  • 29
  • 1
    Possible duplicate of [What is the difference between char \* const and const char \*?](https://stackoverflow.com/questions/890535/what-is-the-difference-between-char-const-and-const-char) – Yennefer May 12 '19 at 12:51

1 Answers1

0

"Top" is a constant. The compiler sees the characters and understands this is not a modifiable data.

Your output method demands a pointer to a char array. This means to a pint in memory where there is a string of varying length. To accomplish what you need to do try this:

      char cstr[10];
      strcpy(cstr,"Top");
      output(-11,6,cstr);
Itamar Kerbel
  • 2,508
  • 1
  • 22
  • 29