I have the following old c code.
const char *c[3]; c[0] = "ABC"; c[1] = "EFG"; c[2] = 0; c_function(c);
Now, I need to use Python to call old c function. I have the following code.
c_names = (c_char_p * 3)() c_names[0] = "ABC"; c_names[1] = "EFG"; // c[2] = 0?? libc = CDLL("c_library.dll") libc.c_function(c_names)
May I know what is the Python equivalent for c[2] = 0;
?
Advertisement
Answer
None
and 0
both work:
>>> import ctypes >>> x=ctypes.c_char_p(0) >>> x c_char_p(None) >>> x=ctypes.c_char_p(None) >>> x c_char_p(None)