title: Creating a brute-force algorithm in C++
body: <p>I am trying to make a brute-force algorithm in C++, to solve problems. I have previously made a brute-force algorithm in Python but this used a 3rd party library, which means I can't convert it to C++. I quite like this design, that I have found;</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main() {
      string characters = "abcde";
  
      int length = 5;
      string word = "";
      for(int i = word.length(); i &lt;= length; i++) {
          for(int l = 0; l &lt; characters.length(); l++) {
              word += characters[l];
              cout &lt;&lt; word &lt;&lt; "\n";
          }
      }
      return 0;
  }
  </code></pre>
  
  <p>, but due to some bug(s), its output is:</p>
  
  <pre><code>abcdeabcde
  abcdeabcdea
  abcdeabcdeab
  abcdeabcdeabc
  abcdeabcdeabcd
  abcdeabcdeabcde
  </code></pre>
  
  <p>and so on...
    The result, that I need is:</p>
  
  <pre><code>a
  b
  c
  d
  e
  aa
  ab
  ac
  ad
  ae
  ba
  bb
  bc
  ...
  </code></pre>
  
  <p>Thanks In Advance :)</p>
  
  <p>Any help is appreciated :)</p>