I am writing a program that is quite complicated compared to what I have considered so far. In any case, at some point I have to write a function that will manipulate the list of structures. I am trying to make this question as simple as possible, so I wrote a fairly simple piece of code for reference only.
Here's what: first I call testf from another function, giving it a real current , as well as i with a value of 0. This means that testf will call itself about 100 times before it starts accessing the rest of the code. This is when all generated testf instances begin to resolve.
void testf(listnode *current, int *i) { wordwagon *current2; current2 = current; if (*i < 100) { *i = *i + 1; current2 = current2->next; testf(current2, i); } current = current->next; return; }
If, for example, I have enough connection list nodes at my disposal, current = current->next; is the correct way for the "last" function testf to access and edit the value of the caller current2 (which is this current function), or am I terribly wrong? If so, what is the way to make changes to the function variables of the calling party from the called function and make sure that they do not disappear as soon as the called function returns? I find it hard to understand how pointers work.
It is very likely that I left important information or that I did not ask my question clearly enough. Please let me know if this is the case, so I can edit everything you need.
Thanks in advance.
source share