title: C function called from Python via ctypes returns incorrect value
body: <p>I have written a simple function in C that raises a given number to a given power. The function returns the correct value when I call it in C, but when I call it in Python it returns a different, incorrect value.</p>
  
  <p>I created the shared file using the command:
  <code>$ gcc -fPIC -shared -o test.so test.c</code></p>
  
  <p>I have tried different configurations of the C function, some of which return the expected value and some of which do not. For example, when my function a simple square using <code>return x*x</code>, without a <code>for</code> loop, it returned the correct value in Python.</p>
  
  <p>I hope to eventually be able to call a C function in python that will return a two-dimensional C array.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  float power(float x, int exponent)
  {
      float val = x;
      for(int i=1; i&lt;exponent; i++){
          val = val*x;
      }
      return val;
  }
  </code></pre>
  
  <pre class="lang-py prettyprint-override"><code>from ctypes import *
  
  so_file = '/Users/.../test.so'
  functions = CDLL(so_file)
  
  functions.power.argtype = [c_float, c_int]
  functions.power.restype = c_float
  
  print(functions.power(5,3))
  </code></pre>
  
  <p>I obtain the expected output of 125.0 when I call the function in C, but when I call the function in python, it returns a value of 0.0.</p>
  
  <p>This is my first time using ctypes. Have I made an obvious error that is causing the function to miscalculate?</p>