i ran into trouble with this code.
thats maybe because it isnt mine alone.
void swap(char *, int, int);
void permut(char *string, int k); //k = number of chars
int main ()
char a = "abc";
void permut(char *string, int k)
if (k == strlen(string))
swap(string, k, i);
void swap(char *string, int k, int i)
hold = string[k];
string[k] = string[i];
string[i] = hold;
the program works fine but i dont really understand the codeflow.
the for statement in the permut function doesnt make much sense to me because the first time it is called, i is set to zero.(value of k right?). the swap function gets called by permut. but isnt the only thing swap is doing setting string = string and so forth....?
before i forget about it, whats about that permut function?
it calls itself a few times and terminates with printing the string.
why is the string printed more than once, when actually it terminates itself after having printed the string once?
is the function permut overlaying itself?
help would be appreciated. thanks