
int func(int) versus int func(int *) efficacy.
Ori:
Quote:
>Hello,
>I am not a professional programmer.
>I have been told that the function: ' int func(int) ' is faster then
>the function ' int func(int *) ' .
Either it is faster, slower or the same. That's called trichotomy.
Quote:
>Obviously, both functions do the same.
Sort of. Both can accomplish the same purpose, perhaps.
Quote:
>If anybody knows why, I will appreciate the answer.
Why? You mean why pass an address rather than the value? The answer is not
for speed, either way. You pass the address if you are going to change the
contents of the variable in the called function, and you want it to change in
the routine that calls the function also. If you just want the value passed,
then you don't use an address. Someone who passes the address because they
think it is faster is incompetent and needs further training.
Quote:
>Thank You Very Much,
You're double-extra peachy welcome.
--
C-FAQ ftp sites: ftp://ftp.eskimo.com ftp://rtfm.mit.edu
Hypertext C-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-FAQ Book: ISBN 0-201-84519-9.
Want Software? Algorithms? Pubs? http://www.infoseek.com