How do I initialize a fixed-size character array, such as char a[32], field of a structure using ctypes? Example:
import ctypes
class MyStructure(ctypes.Structure):
_fields_ = [("a", ctypes.c_char * 32)]
a = (ctypes.c_char * 32)(*b"Hi!")
mystruct = MyStructure(a=a)
This gives me an error:
Traceback (most recent call last):
File "...", line ..., in <module>
mystruct = MyStructure(a=a)
TypeError: expected bytes, c_char_Array_32 found
Additional info: this is a MWE of a C++ DLL that has a structure with fixed-size character arrays that act as strings (e.g., names of things).