Hello frnds. I want to knw tht how can we send an array by value in c.
abrarsyed 0 Newbie Poster
Recommended Answers
Jump to PostThe short answer is you can't. The long answer is you can if you aren't pedantic about it.
An array can be copied by value by wrapping the array in a structure and then passing an instance of that structure. When the structure instance is copied, the array goes with …
Jump to Post@Sokurenko: I'm not the kind of guy who down-votes posts willy-nilly (unless you're being condescending and a complete ass), but your post is... not what the OP is asking for. Pass by value, not reference. Yours is reference. Granted, your code is instructive to new coders and you're not rude, …
Jump to Post@Deceptikon: Back in the days of Turbo C, I remember folks saying never put an array in the arguments, and instead use its pointer AND the same thing about struct's.
While it's true for struct instances, arrays have always been passed "by pointer", even in the prehistory of …
Jump to PostThat's certainly one valid way to pass multiple values to a function, but it's not advisable. Your proposed solution is overly complicated, which makes it hard to document, hard to read, and hard to debug.
Furthermore, it seems in your case to be totally unnecessary. Since you're not doing anything …
All 15 Replies
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
Sokurenko 42 Junior Poster
Sokurenko 42 Junior Poster
DeanMSands3 69 Junior Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
Sokurenko 42 Junior Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
DeanMSands3 69 Junior Poster
abrarsyed 0 Newbie Poster
abrarsyed 0 Newbie Poster
abrarsyed 0 Newbie Poster
Trentacle 112 Junior Poster in Training
Sokurenko 42 Junior Poster
abrarsyed 0 Newbie Poster
Trentacle 112 Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.