title: Brute Force Character Generation in C++
body: <p>So I'm trying to make a brute force string generator to match and compare strings in CUDA. Before I start trying to mess around with a language I don't know I wanted to get one working in C++. I currently have this code.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;cstdlib&gt;
  
  using namespace std;
  
  
  int sLength = 0;
  int count = 0;
  int charReset = 0;
  int stop = 0;
  int maxValue = 0;
  string inString = "";
  static const char charSet[] = //define character set to draw from
  "0123456789"
  "!@#$%^&amp;*"
  "abcdefghijklmnopqrstuvwxyz"
  "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int stringLength = sizeof(charSet) - 1;
  
  
  char genChars()
  {
          return charSet[count]; //Get character and send to genChars()
  }
  
  int main()
  {
      cout &lt;&lt; "Length of string to match?" &lt;&lt; endl;
      cin &gt;&gt; sLength;
      cout &lt;&lt; "What string do you want to match?" &lt;&lt; endl;
      cin &gt;&gt; inString;
      string sMatch(sLength, ' ');
      while(true)
      {
          for (int y = 0; y &lt; sLength; y++)
          {
              sMatch[y] = genChars(); //get the characters
              cout &lt;&lt; sMatch[y];
  
              if (count == 74)
              {
                  charReset + 1;
                  count = 0;
              }
              if (count == 2147000000)
              {
                  count == 0;
                  maxValue++;
              }
          }
          count++;
          if (sMatch == inString) //check for string match
          {
              cout &lt;&lt; endl;
              cout &lt;&lt; "It took " &lt;&lt; count + (charReset * 74) + (maxValue*2147000000) &lt;&lt; " randomly generated characters to match the strings." &lt;&lt; endl;
              cin &gt;&gt; stop;
          }
          cout &lt;&lt; endl;
      }
  }
  </code></pre>
  
  <p>Now this code runs and compiles but it doesn't exactly do what I want it to. It will do 4 of the same character, EX. aaaa or 1111 and then go onto the next without incrementing like aaab or 1112. I've tried messing around with things like this</p>
  
  <pre><code>for (int x = 0; x &lt; sLength; x++)
  {
      return charSet[count-sLength+x];
  }
  </code></pre>
  
  <p>Which in my mind should work but to no avail.</p>