0

I declared the following char* and tried to pass it to a function that requires a char * as the 3rd argument:

char *echo;
prompt = ssh_userauth_kbdint_getprompt(primarySession, 0, echo);

However, I get the error:

error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]

I also tried declaration as char echo; and the passed argument as &echo. But I don't really need the value that this function changes in echo. So I wanted to pass NULL, but I guess I expected that to be a const. I also tried this trick:

char echo;
prompt = ssh_userauth_kbdint_getprompt(primarySession, 0, (char *)(&echo));

Still no success. Suggestions?

Community
  • 1
  • 1
vlad417
  • 193
  • 1
  • 2
  • 9
  • 1
    Forget about `echo`. It is not about your `echo`. It is about `prompt`. How's your `prompt` declared? – AnT Dec 04 '12 at 20:25

3 Answers3

3

Look at the declaration of that function:

const char *
ssh_userauth_kbdint_getprompt (ssh_session session, unsigned int i, char *echo)

Thus it is prompt that needs to be a const char * instead of a char *.

melpomene
  • 81,915
  • 7
  • 76
  • 137
cnicutar
  • 172,020
  • 25
  • 347
  • 381
  • Ah yes, I was distracted away from even looking at the return type since the error was claimed to have occurred at column 63, directly over top `&echo`.... – vlad417 Dec 04 '12 at 20:42
1

The problem is with return value of that function, not any of its parameters.

piokuc
  • 24,264
  • 10
  • 66
  • 98
0

Probably the error is not where you think, but in the return type. I'd guess that your prompt variable is char* where the function returns a char const*.

Jens Gustedt
  • 74,635
  • 5
  • 99
  • 170