简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM