Shyne
Shyne

Reputation: 339

Issue with recursive function arguments

I'm writing a simple recursive function, but I'm having issues calling it because of the arguments types. I'm new to C++ and typed languages, so it may be a really simple fix I don't understand.

The error:

error: no matching function for call to 'find(char*&, char* [4], const unsigned int&)'
    find(charset, word, length);
                              ^

The function definition:

void find(char * charset, char * word, const unsigned int len_) {};

The function call:

const unsigned int length = 4;
char * charset = genCharset(33, 94);
char * word[length];
find(charset, word, length);

Hope someone can point out the problem and provide an answer.

Upvotes: 0

Views: 51

Answers (1)

Fantastic Mr Fox
Fantastic Mr Fox

Reputation: 33864

char * word[length]; is an array of char * aka:

[char* 1, char * 2, char* 3, ...]

Your function is expecting just a char*. Since it seems you are expecting a character set, you probably just want char charset[4], or better yet std::vector<char> or std::array<char>.

Upvotes: 1

Related Questions