title: Function to print all combination of entered characters is not printing as expected
body: <p>The goal of my program is to print all combinations of characters that a user may enter as long as it is under the max length. I am able to correctly fill the array with characters, show the number of characters entered, and the max length of the string (entered by the user). However, the functions do not print as expected. In theory if the user entered <strong>2 characters (a, b) with a max length of 2</strong>, the program should output this...</p>
  
  <pre><code>a
  b
  aa
  ab
  ba
  bb
  </code></pre>
  
  <p>Instead, my code is outputting this and I can not figure out why...</p>
  
  <pre><code>a
  ab
  </code></pre>
  
  <p>Below are my two functions. My main function gets the user input for the number of characters, the character array, and the max length of the string to be printed out. After, it calls the <strong>generatePassword</strong> function. Any help would be appreciated!</p>
  
  <pre><code>int crack(char *characters[], int i, char s[], int numCharacters, int passwordLength) {
      if (i==0) {
          printf("%s\n", s);
          return 0;
      }
      for (int j = 0; j &lt; numCharacters; j++) {
          char string[MAX];
          strcpy(string, strcat(s, characters[j]));
          crack(characters, i-1, string, numCharacters, passwordLength);
      }
      return 0;
  }
  
  
  void generatePassword(char* characters[], int numCharacters, int passwordLength) {
  
      for (int i = 1; i &lt; passwordLength; i++) {
          char s[MAX] = "";
          int num = crack(characters, i, s, numCharacters, passwordLength);
      }
  
  }
  
  int main (int argc, char *argv[]) {
  
          if (argc &lt; 2) {
                  printf("ERROR: Program did not execute due to lack of arguments.\n");
                  return -1;
          }
  
          int numCharacters;
          numCharacters = atoi(argv[1]);
          int passwordLength;
          passwordLength = atoi(argv[numCharacters+2]);
  
          for (int i = 0; i &lt; numCharacters; i++) {
                  if (strlen(argv[i+2]) &gt; 1) {
                          printf("ERROR: You can only input one character at a time.\n");
                          return -1;
                  }
          }
  
          if (argc != (numCharacters+3)) {
                  printf("ERROR: Invalid number of arguments.\n");
                  return -1;
          }
  
          char *charArray[numCharacters];
  
          for (int i = 0; i &lt; numCharacters; i++) {
                  charArray[i] = argv[i+2];
          }
  
          generatePassword(charArray, numCharacters, passwordLength);
          return 0;
  }
  
  </code></pre>
  
  <p>EDIT: I have added my main function to the code to show how I call generatePassword. The goal of the code is to get the number of characters going to be entered, the characters, and the max length of the string from the command line in the linux environment. </p>