473,473 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

size of struct with pointers and function pointers

2 New Member
Hi,

I following structure
Expand|Select|Wrap|Line Numbers
  1. typedef struct
  2. {
  3. UINT32 abc;
  4. int (*f)(int a, intb);
  5. char *ptr;
  6. } my_struct;
  7.  
  8. main()
  9. {
  10. my_struct myParams;
  11. sizeof(myParams);
  12. }
  13.  
Assume int is 4 bytes and char is 1 byte. I know the size of structure without pointers inside. But I am not sure with pointers and function pointers. Is it 4+4+4(12) or something else??

Thanks in advance.
Johnny
Jul 2 '10 #1
2 1707
Dheeraj Joshi
1,123 Recognized Expert Top Contributor
Yes. Size is 12.

Regards
Dheeraj Joshi
Jul 2 '10 #2
Banfa
9,065 Recognized Expert Moderator Expert
On a 32 bit system, on a 64 bit system your pointers are likely to be 8 bytes not 4.
Jul 2 '10 #3

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

Similar topics

1
by: Thomas Connolly | last post by:
Hello list, No one seems to be replying to my request on the interop group so I thought I would try here. Can someone please help me with this? I have a C struct containing function pointers like...
2
by: Xiangliang Meng | last post by:
Hi, all. As far as I know, the speical arithmetic operator on void pointer is an externsion in GNU CC. However, I could not find the relative topics in C99. Would someone like to help me find...
3
by: Takeshi | last post by:
I have code as ff: typedef double* (*DBLPTRFUNCPTR)(int) ; typedef int* (*INTPTRFUNCPTR)(int) ; typedef double (*DBLFUNCPTR)(int) ; typedef int (*INTFUNCPTR)(int) ; etc .... typedef struct
10
by: gmtonyhoyt | last post by:
It's been mentioned to me that, in standard c, that you can have structures behave very much like classes in relation to something to do with function calls within a structure. Now, I didn't get...
38
by: maadhuu | last post by:
does it make sense to find the size of a function ??? something like sizeof(main) ??? thanking you ranjan.
3
by: Thomas Connolly | last post by:
Hello list, No one seems to be replying to my request on the interop group so I thought I would try here. Can someone please help me with this? I have a C struct containing function pointers like...
0
by: Michael | last post by:
Hi developers. I´m trying to migrate a C++ sample from the Canon SDK Version 7.1 into C#. I have come across lots of pit falls (and luckily solved them) but now I´m stuck with some of the nice...
45
by: noridotjabi | last post by:
What is the purpose of the function pointer? Why do you need a pointer to a function. I cannot really think of any application where this is the only or even easiest solution to a problem. I'm...
12
by: Googy | last post by:
Hi!! Can any one explain me the meaning of following notations clearly : 1. typedef char(*(*frpapfrc()))(); frpapfrc f; 2. typedef int (*(arr2d_ptr)()); arr2d_ptr p; 3. typedef int...
32
by: copx | last post by:
Why doesn't the C standard include generic function pointers? I use function pointers a lot and the lack of generic ones is not so cool. There is a common compiler extension (supported by GCC...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.