Question

In C programming, what is the difference between passing a struct by pointer vs. by value?

In C programming, what is the difference between passing a struct by pointer vs. by value?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

When struct is passed by value, the data is copied on to stack. If data is small, stuct by value may be acceptable. But when data is large,it is not acceptable since the stack will be overflown causing improper functioning of system.

Struct by value can be used when we want to return multiple values from the function. The values are put in a struct and can be return using the struct.

There is not any difference in the code. It's just the background processing of data that differs.

void class(struct student s,int strength)
{...}

void class(struct student *s,int strength)
{...}
Add a comment
Know the answer?
Add Answer to:
In C programming, what is the difference between passing a struct by pointer vs. by value?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT