Now if you call a function, swap like increment or cube or swap, or in this case, foo, those variables are the parameters to that function, end up getting stored next in memory.
现在如果你调用一个函数,像increment或者cube或者,或者在这个例子里,foo,这些变量都是,函数的参数,在内存中存储。
X So here I'm declaring another variable called X, and this is totally legitimate because I already know that if I'm implementing a function like swap or increment, I can absolutely take input.
这里我声明另一个变量,这个完全是合法的因为我已经知道,如果我执行一个像swap,或,increment的函数,我完全可以携带输入。
I have to change the prototype of this function to say that swap no longer takes an int per se or another int per se, but rather it takes two pointers, two ints, and in fact, it's on the very last page if you're still flipping.
我改变了这个函数的原型,来说明swap不再携带那两个int数本身,而是携带两个指针,两个整型数指针,实际上,它是在最后那页上。
So pictorially, it's as though there's now some other part of the blackboard here, maybe way up here where I can put anything I want that's accessible to main, that's accessible to swap, that's accessible to increment or any other function I might implement because it is, in fact, global.
绘画般地,它是在这里黑板上的其他部分,可能在这里的上面,我在哪里可以放置这些东西,使它们可以被main函数使用,可以被swap函数使用,可以被increment函数使用,或者我所实现的其它函数,因为它实际上是一个全局变量。
应用推荐