473,320 Members | 2,012 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,320 software developers and data experts.

What is the advantage of using a pointer to a structure as a parameter to a function?

What is the advantage of using a pointer to a structure as a parameter to a funtion, instead of the structure itself?
-the code is easier to read

-it is more efficient because the structure is not copied

-there is no difference; it is a matter of style

-passing a structure as a parameter is not allowed
Aug 5 '07 #1
4 4521
JosAH
11,448 Expert 8TB
What is the advantage of using a pointer to a structure as a parameter to a funtion, instead of the structure itself?
-the code is easier to read

-it is more efficient because the structure is not copied

-there is no difference; it is a matter of style

-passing a structure as a parameter is not allowed
What programming language are you talking about? C? C++? If so, you'd better
ask that question in the C/C++ forum.

kind regards,

Jos
Aug 5 '07 #2
bartonc
6,596 Expert 4TB
Sounds like a homework question to me. If so, please check out our Posting Guidelines. Thanks.
Aug 5 '07 #3
pbmods
5,821 Expert 4TB
Changed thread title to better describe the problem.

Moving to the C forum.
Aug 5 '07 #4
weaknessforcats
9,208 Expert Mod 8TB
You use a pointer to a structure as a funciton arguiment rather than the structure itself to a) let the called function modify the variable in the calling function, b) avoid making a copy of the struct variable.

Making copies takes time and if the struct is large, it eats memory. Copies also involve considerations of "deep copy" versus "shallow copy".
Aug 5 '07 #5

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

Similar topics

11
by: Rajesh | last post by:
Dear All, Please let me know the advantage of function pointer? Is it fast calling function using function pointer? Is it possible to use function pointer to optimise code? Thanks and regards...
3
by: joe bruin | last post by:
hello all. i am trying to get rid of some warnings and do "the right thing". although in this particular case, i am not sure what the right thing is. the code: typedef struct {
9
by: gold | last post by:
Hello all, I want know abt wht kind of datastructures using both C & C++ internally. Some were said heap, others said tree anyone can explain brief?
15
by: damian birchler | last post by:
Hi I'm wondering of what type a structure is. Of course, it is a _structure_, but an array isn't an _array_ either. So of what type is a structure? I'd say a pointer, am I right?
2
by: John Regan | last post by:
Hello All I am trying to find the owner of a file or folder on our network (Windows 2000 Server) using VB.Net and/or API. so I can search for Folders that don't follow our company's specified...
12
by: mohan | last post by:
Hi All, How to implement virtual concept in c. TIA Mohan
14
by: code break | last post by:
what is the difference in this pointers decalarition ? int *ptr; and int (*ptr);
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
6
by: red floyd | last post by:
I have a struct that maps onto a set of memory mapped registers. I access this via a pointer. Is it better to declare it as pointer to a volatile struct, or to declare the individual members as...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.