Skip to content
Advertisement

How do I get values from a C dll array pointer using ctypes and Python

A DLL provides a pointer to a 1D array in my C code like this:

JavaScript

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.

JavaScript

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?

Advertisement

Answer

You can define restype:

JavaScript

Then, you can randomly access to each element:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement