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