0

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.

1 Answer 1

1

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>.

Sign up to request clarification or add additional context in comments.

2 Comments

Why would vector<char> be better than char array? Most of the type it is to use it as a buffer, so array will have better performance.
@AntoninGAVREL, sure, then use std::array, don't use char buffers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.