title: Translate a simple bruteforcer from C# to C
body: <p>I'm trying to translate <a href="https://stackoverflow.com/a/1393146">a simple bruteforcer</a> from C# to C in order to do some benchmarks. I'm assuming the logic of the subject is reasonable, so I've decided to translate this, but I'm not so good in C. This is the original code:</p>
  <pre><code>private static char[] characters =
      new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J' };
  
  // length: The length of the string created by bruteforce
  public static void PerformBruteForce(int length) {
      int charactersLength = characters.Length;
      int[] odometer = new int[length];
      long size = (long)Math.Pow(charactersLength, length);
  
      for (int i = 0; i &lt; size; i++) {
          WriteBruteForce(odometer, characters);
          int position = 0;
          do {
              odometer[position] += 1;
              odometer[position] %= charactersLength;
          } while (odometer[position++] == 0 &amp;&amp; position &lt; length);
      }
  }
  
  private static void WriteBruteForce(int[] odometer, char[] characters) {
      // Print backwards
      for (int i = odometer.Length - 1; i &gt;= 0; i--) {
          Console.Write(characters[odometer[i]]);
      }
      Console.WriteLine();
  }
  </code></pre>
  <p>this is the code that is going to be the translated one:</p>
  <pre><code>void WriteBruteForce(int *odometer, char *characters) {
      for (int i = len(*odometer) - 1; i &gt;= 0; i--) {
          puts(characters[odometer[i]]);
      }
  }
  
  void PerformBruteForce(char *characters, int maxLength) { // max = maximum length
      int characters_length = len(characters);
      int odometer[maxLength];
      long size = (long)pow(characters_length, maxLength);
  
      for (int i = 0; i &lt; size; i++) {
          WriteBruteForce(odometer, characters);
          int position = 0;
  
          do {
              odometer[position]++;
              odometer[position] %= characters_length;
          } while (odometer[position++] == 0 &amp;&amp; position &lt; maxLength);
      }
  }
  </code></pre>
  <p>but I'm getting many errors (actually 4, but they are very aggravated), maybe some lines of code are not even translated. The charset is passed to the first parameter of <code>PerformBruteForce</code>.</p>
  <p>Can a skilled guy in C help me to get the errors in the C code, and fix them?</p>
  <p>Errors:</p>
  <blockquote>
  <p>code.c: In function ‘WriteBruteForce’:</p>
  <p>code.c:21:15: warning: implicit declaration of function ‘len’ [-Wimplicit-function-declaration]</p>
  <p>for (int i = len(*odometer) - 1; i &gt;= 0; i--) {</p>
  <p>code.c:21:2: error: declaration of non-variable ‘len’ in ‘for’ loop initial declaration</p>
  <p>for (int i = len(*odometer) - 1; i &gt;= 0; i--) {</p>
  <p>^~~</p>
  <p>code.c:22:8: warning: passing argument 1 of ‘puts’ makes pointer from integer without a cast &gt;[-Wint-conversion]</p>
  <p>puts(characters[odometer[i]]);</p>
  <p>In file included from code.c:1:0:
  /usr/include/stdio.h:697:12: note: expected ‘const char *’ but argument is of type ‘char’</p>
  <p>extern int puts (const char *__s);</p>
  </blockquote>