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
  • 313
  • 1
  • 3
  • 10

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
  • 84,125
  • 8
  • 85
  • 148
cnicutar
  • 178,505
  • 25
  • 365
  • 392
  • 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
  • 25,594
  • 11
  • 72
  • 102
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
  • 76,821
  • 6
  • 102
  • 177