How to pass char** in python ctype and once it is modified in 'C++' code how do i access it
-
I'm trying to access a c++ function from python using ctypes int func(void**, char**policy_names) { // 1.allocate memory to policy_names // 2.fill policy_names with policy names ex: policy_names[0] ="hi" policy_names[1]="bye" return 0; } memory allocation happens in c++ func mentioned above and the policy_name is filled with list of strings . python code: policy_list = POINTER(c_char)() Handle = c_void_p() Getpolicy = lib.func() func.argtypes = [c_void_p, POINTER(POINTER(c_char))] x = GetPolicy(Handle, policy_list) Questions I have is Is it the right way of passing char** args using ctypes ?? once the c++ function allocates , fills the policy_names how do i access it back in python??
-
Answer:
I some how fixed it after some research it should be the following way: I'm trying to access a c++ function from python using ctypes python code: policy_list = POINTER(c_char_p)() Handle = c_void_p() Getpolicy = lib.func() x = GetPolicy(Handle, policy_list) how to access it is policy_list[0], .....
Ram at Stack Overflow Visit the source
Related Q & A:
- How can i access the number of questions asked on stackoverflow?Best solution by Meta Stack Overflow
- How do I access the parent panel?Best solution by Stack Overflow
- How can I access my localhost from my Android device?Best solution by Stack Overflow
- How can I access file in localhost?Best solution by Stack Overflow
- How do I access a Yahoo group archive?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.