473,397 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Pointer to a Structure to pass to a C function

Let me preface this by I am very new to python programming...
I was looking at an old discussion about this that basically showed how to create a pointer to a structure to send to a C function in a DLL, it was...
Expand|Select|Wrap|Line Numbers
  1. from ctypes import *
  2.  
  3. class STUDENT(Structure):
  4.     _fields_ = [('name', c_int), ('id', c_int), ('addition', c_ubyte)]
  5.     buffer = (c_byte * 1024)()
  6.     buffer_p = pointer(buffer)
  7.     student_p = cast(buffer_p, POINTER(STUDENT))
My questions are about the line of code:
"buffer = (c_byte * 1024)()"

1) Is the purpose of the 1024 simply to allocate enough bytes to hold the structure?

2) If so, should there a better way to allocate a buffer of the correct size?
Dec 16 '13 #1
0 1239

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: cylin | last post by:
Dear all, I met a char pointer problem. please help,thanks. How to change the the value which is pointed by a char pointer by a function? for example,...
5
by: Newsgroup - Ann | last post by:
Gurus, I have the following implementation of a member function: class A { // ... virtual double func(double v); void caller(int i, int j, double (* callee)(double)); void foo() {caller(1,...
2
by: glen stark | last post by:
Okay, I know that a function pointer and member function pointer have different types. Is it kosher to convert a member function pointer to a regurlar function pointer (with the same...
37
by: Ben | last post by:
Hi, there. Recently I was working on a problem where we want to save generic closures in a data structure (a vector). The closure should work for any data type and any method with pre-defined...
10
by: Robert | last post by:
Hello all, I am a C programmer learning C++. And I am confused with function Pass by Pointer * or Pass by Reference &. Function pass by pointer like: void func(int * x) And function pass by...
3
by: Thomas Barth | last post by:
Hi, I dont understand the third argument of this function. This function expect the address of a function, but what does "void *(*funktion)(void *)," mean? I am confused by so many "wildcards" :-)...
5
by: s88 | last post by:
Howdy: the follows is my program, I wanna change my structure array pointer in the function "testfunc", but I fail..., I also try to call the testfunc by reference, but the compiler says...
2
by: TN | last post by:
I have a bit of C code, that creates an instance of a .Net class that has been built as a type library. Everything is working as expected, I can pass strings to methods in the object. What I...
3
by: dice | last post by:
Hi, In order to use an external api call that requires a function pointer I am currently creating static wrappers to call my objects functions. I want to re-jig this so I only need 1 static...
1
by: pheres | last post by:
Hi, I'm trying to pass pointers to member functions around in my code. The test with pointers to non-member function works fine: Code: void callOut( void (*callback)() ) { callback();
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.