Last night I encountered a problem with a function I wrote to add an affect to a linked list. It took 3 parameters, each AFFECT_DATA pointers. (AFFECT_DATA *af, AFFECT_DATA *first, AFFECT_DATA *last) This function was just a wrapper for the LINK(), although I also tried writing my own linking function, but neither worked. Anyway, I fixed the issue by changing first and last to AFFECT_DATA **first, AFFECT_DATA **last, and fed *first and *last to LINK().
I have a theory on why this is necessary that I have been entertaining, and since I already average about a post every 2 hours since I joined, I figured I'd run it by you fine people so you can correct me if I'm wrong before I get attached to the idea.
(I have no formal training, etc, so I learn things by watching what happens when things break, or, failing that, I just make stuff up)
Anyway, my theory is that it is related to this "call by value" and "call by reference" crap, which I always confuse, but I looked up recently, and wikipedia, etc says that C uses call by value by default, but you can make it use call by reference by passing pointers.
However, this "linking" incident has led me to believe that C always
calls by value, and when you pass a pointer, you pass the value (i.e., address) of the pointer, which is fine for most things, unless you try to set the pointer itself, in which case you have to take another level of indirection in order to get the desired results.