Found 1452 Articles for C

How to wrap python object in C/C++?

Gireesha Devara
Updated on 24-Aug-2023 16:01:06

212 Views

To wrap existing C or C++ functionality in Python, there are number of options available, which are: Manual wrapping using PyMethodDef and Py_InitModule, SWIG, Pyrex, ctypes, SIP, Boost.Python, and pybind1. Using the SWIG Module Let’s take a C function and then tune it to python using SWIG. The SWIG stands for “Simple Wrapper Interface Generator”, and it is capable of wrapping C in a large variety of languages like python, PHP, TCL etc. Example Consider simple factorial function fact() in example.c file. /* File : example.c */ #include // calculate factorial int fact(int n) ... Read More

What is the difference between ++i and i++ in c?

Jayashree
Updated on 12-Sep-2023 02:57:07

31K+ Views

In C, ++ and -- operators are called increment and decrement operators. They are unary operators needing only one operand. Hence ++ as well as -- operator can appear before or after the operand with same effect. That means both i++ and ++i will be equivalent.i=5; i++; printf("%d", i);and i=5 ++i; printf("%d", i);both will make i=6.However, when increment expression is used along with assignment operator, then operator precedence will come into picture. i=5; j=i++;In this case, precedence of = is higher than postfix ++. So, value of i is assigned to i before incrementing i. Here j becomes 5 and i becomes 6.i=5; ... Read More

Advertisements