I would like to know how to tell when a function expects pass by reference.
I would like to know how to tell when a function expects pass by reference.
You could look at the prototype for a function to see what arguments it expects, if that's what you mean. Or you could just try it one way, and if you get a compiler error/segmentation fault, try it the other way.
And by pass-by-reference, you do mean via pointers, right?
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
I guess what I'm asking is how to tell just by looking at a prototype if you need to pass the address of a pointer or not.
Well, you could use a man page, online or otherwise. Stick the function into google, possibly along with "c function", and you'll most likely find information about it. There's a long list of websites like this here.
Or you could always look at the header file itself. Look in /usr/include/stdio.h or C:\Dev-C++\Include\stdio.h or whatever, search for the function name, and you'll probably get it. Substitute whatever header file the function is in for stdio.h. If you don't know which header file it's in, search the whole directory. But you don't usually need to do this unless it's a very uncommon function or you don't have internet access.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.