I'll say in advance that I'm asking about pointers to pointers, so my words may be a bit vague, but try to stay with me :)
I am trying to understand how changing a pointer passed as an argument takes effect outside the scope of the function. So far this is what I understand: if a pointer is passed as an argument to a function, I can only change what the pointer points to, and not the pointer itself (I'm talking about a change that will take effect outside the scope of the function, as I said). And if I want to change what the pointer is pointing to, I have to pass a pointer to a pointer.
Am I right so far?
Also, I've noticed that when I have a struct that holds some pointers, if I want to initialize those pointers I have to pass the struct
to the initialization function as a pointer to pointer. Is this for the same reason?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…