translating arrays from c to python ctypes
Question: I have the below arrays on C how can i interpert them to ctypes datatypes
inside structre

    
    
    struct a {
    
    BYTE    a[30];
    CHAR    b[256];
    };
    

should i interpert a fixed array as the datatype * the size i want like the
below and if yes how can i call this structure as a parameter to fun that
takes instance from this structure

    
    
    class a(structure) :
    
    _fields_ = [ ("a",c_bytes*30 ),
                     ("b",c_char*256 ),]
    


Answer: You're on the right track. You're probably just missing the `byref()`
function. Assuming the function you want to call is named *print_struct*, do
the following:

    
    
    from ctypes import *
    
    class MyStruct(Structure):
        _fields_ = [('a',c_byte*30), ('b',c_char*256)]
    
    s = MyStruct() # Allocates a new instance of the structure from Python
    
    s.a[5] = 10 # Use as normal
    
    d = CDLL('yourdll.so')
    d.print_struct( byref(s) )  # byref() passes a pointer rather than passing by copy
    

