Passing structure by reference or pointer?
Given the structure below:-
Code:
typedef struct {
int a;
word b;
} process;
By reference:-
Code:
main()
{
process work;
/* init structure variable */
...
do_something( &work );
...
}
By pointer:-
Code:
main()
{
process work;
process *ptr_work = &work;
/* init structure variable */
...
do_something( ptr_work );
...
}
Which would be an optimal performance approach if I want to pass a structure into a function?
Also, some reading up here and there came across to a site that says "by reference" is a C++ solution (see http://cplus.about.com/od/cprogrammi.../aa010402a.htm ). I have this impression that it is available in C as well, so the other question I have is if it is really a C++ approach, does that mean most, if not all, C compilers would give me error if I use by reference method?