title: How do I get values from a C dll array pointer using ctypes and Python
body: <p>A DLL provides a pointer to a 1D array in my C code like this:</p>
  <pre><code>__int16 *data = Msg_RowAt(surfaceMsg, rowIdx);
  
  //access the values like this
  data[iterator]
  </code></pre>
  <p>I'm building a Python project where I need to access the values of the same array. I've tried the following but get an access violation when I try iterate surfaceData.</p>
  <pre><code>surfaceDataPtr = Msg_RowAt(surfaceMsg, row)
  ptr = ctypes.POINTER(ctypes.c_int16)
  surfaceData = ctypes.cast(surfaceDataPtr, ptr)
  print(&quot;ptr: &quot; + str(surfaceData))
  print(&quot;val: &quot; + str(surfaceData[1]))
  </code></pre>
  <p>I'm accessing the wrong memory location but I'm not too sure what I've done wrong. Can anyone see what I'm doing wrong?</p>