Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: pointers...

Thread Tools

Re: pointers...

Simon Biber
Posts: n/a
"geo" <geometrikal@hhoottmmaaiill> wrote:
> and then i had a function which used this structure. What
> is the best programming practice:
> void function(struct random_struct * r) {
> .......
> }
> function(&random);
> or:
> void function(struct random_struct r) {
> .......
> }
> function(random);

There is no 'best programming practice'. They do very
different things. Use the former when you want to modify
the existing copy of the struct in place, and use the
latter when you want to have a fresh copy that you can
modify, without changing the original.

If you don't want to modify it at all, the function
should take a pointer to const struct random_struct.

comp.lang.c.moderated - moderation address: Removed)
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off