在 C 语言中,有两种方法将参数传递给函数,对吧?其中之一是按地址传递。你不需要总是传递指针吗?
我还没有尝试过任何东西,只是想知道它的逻辑/理论。我想了解一下。
所有 C 参数都是“按值传递”
void fn (int i)
{
/* You can change i in here but it's only working on a local copy of i
*/
}
void fn(int* ip)
{
/* You can change ip in here but it's only working on a local copy of ip.
* If you change *ip then that will "stick" outside this function.
*/
}