return a tuple c 2b 2b python 3

Solutions on MaxInterview for return a tuple c 2b 2b python 3 by the best coders in the world

showing results for - "return a tuple c 2b 2b python 3"
Alessio
22 Jun 2018
1# C++ CODE
2void divide_modulo(int a, int b, int *div, int *rest)
3{
4    *div  = a / b;
5    *rest = a % b;
6}
7
8# COMPILE WITH
9gcc -o libexample.so -shared example.c
10# OR C++
11g++ -o libfoo.so -shared example.cpp
12
13# PYTHON 3.7 CODE
14import ctypes
15lib = ctypes.cdll.LoadLibrary('./libexample.so')
16
17def divide_modulo(a, b):
18  div = ctypes.c_int(0)
19  rest = ctypes.c_int(0)
20  lib.divide_modulo(a, b, ctypes.byref(div), ctypes.byref(rest))
21  return (div.value, rest.value)
22
23print(divide_modulo(11, 4))
similar questions
queries leading to this page
return a tuple c 2b 2b python 3