June 2017
Beginner to intermediate
274 pages
6h 49m
English
Another common behavior of C functions is filling bytes into a character buffer. We can use the create_string_buffer function of ctypes to allocate such a buffer and then use the result as a parameter for functions that want a string buffer, as shown in the following code example:

Let's look at this code now. We do not need to use the byref function here, because the character bumper is inherently by reference. There's just no other way to do this in C.
There's a pitfall here: one that's been tripping up C programmers for decades. Our string buffer has a specific length, but the function we're passing to it doesn't ...
Read now
Unlock full access