You should use indexing:
>>> p = ctypes.cast("foo", ctypes.POINTER(ctypes.c_char)) >>> p[0] 'f' >>> p[1] 'o' >>> p[3] '\x00'
See the ctypes documentation to learn more about using pointers.
UPDATE . It seems that this is not what you need. Let's try a different approach: first hover over void, increment it and then return it back to LP_c_char:
In [93]: p = ctypes.cast("foo", ctypes.POINTER(ctypes.c_char)) In [94]: void_p = ctypes.cast(p, ctypes.c_voidp).value+1 In [95]: p = ctypes.cast(void_p, ctypes.POINTER(ctypes.c_char)) In [96]: p.contents Out[96]: c_char('o')
It may not be elegant, but it works.
Michaล Bentkowski
source share