c++ - What does this line of code do? -
c++ - What does this line of code do? -
void expand_combinations(const char *remaining_string, string const & s, int rema in_depth) { if(remain_depth==0) { std::cout << s << std::endl; return; } for(int k=0; k < strlen(remaining_string); ++k) { string str(s); str.append(1, remaining_string[k]); expand_combinations(remaining_string+k+1, str, remain_depth - 1); // what? } return; }
on phone call function, it's passing string + integer. become?
remaining_string not string; it's pointer character. hence adding integer moves pointer.
for example, if char *blah = "hello"
, blah+1
point "ello"
.
c++ function
Comments
Post a Comment