So both of these stories involve floating point values, but only in this case am I actually allocating memory.
所以这两个故事都涉及到浮点类型,但是只有那样我们才能真正地分配到内存。
You double click an icon, the program gets loaded into memory, well, conceptually where does your program end up?
双击一个图标,程序就被加载到内存中,那么,程序在哪里结束?
To get any location in memory, to get to any value of the list, I simply have to say which element do I want to get, I know that these things are stored in a particular size multiply that index by 4, add it to start, and then it's in a constant amount of time I can go to that location and get out the cell.
取得列表中的任何一个值,简单说来,想要取得列表中的任何元素,我知道这些元素存在特定的大小中,把下标乘以4,加到start上,然后定位到内存单元,并取出值就是固定的时间了,好的,如果元素以固定大小存储。
Well, again, just as I said verbally a moment ago, if you're going here, you're literally touching, trying to read or change memory that's beyond the boundaries of a chunk of memory that you're supposed to be touching based on its length.
嗯,再次强调,就像我刚才说的,如果你从这里出发,你将依次接触到,试着读取或者改变内存,如果超出了你可以使用的,内存块长度的界限。
You can touch almost any part of memory in the computer systems that you want with your program, but do you want to?
通过你的程序,你可以触及到计算机系统,内存的任意部分,但是那是你想要的吗?
When you double-click a program, it's loaded into RAM.
当你双击一个程序,它被加载到内存中。
B It swaps this one and these two, A and B, but it has no access to main's memory.
它交换了这个和这两个变量,A和,但是它没有介入到main的内存中。
skittles So when you compile a program called A dot out, or skittles or wherever, and you double-click that program, or our in our command line environment, run it with dot slash skittles, that program is loaded Microsoft Word into memory just like Microsoft Word or whatever would be on your own computer.
当你编译一个程序a,out,或者,或其他的,你双击那个程序,或着在我们的命令环境中,采用,/skittles来运行它,那个程序被加载到,内存中,就像,或者你电脑上的其他程序。
So you can think of it as left or right, top to bottom, or whatever, the point is they come next in RAM.
你可以想象它们为left或者right,从上到下,要点是它们在内存中紧随其后。
And when you call a function, one of the things X that happens is whatever your passing in, for instance, X, ; and if this is A, this thing gets copied into A; so at that moment in time of calling increment, I actually have two copies of the same value in memory but they're referred to by different names.
当你调用一个函数,其中发生的一件事情是,不管你输入什么,比如,或者是A,它把这个东西复制到A中;,调用increment的时候,实际上在内存中,有两个同样的值的内存块,但是它们有不同的名字。
I mean what if you're running so many things, what if the user has copied and pasted their thesis and just pasted it at the blinking prompt such that you're now out of memory because your computer is somewhat limited in memory so get string cannot possibly return all those characters or fit all of those characters in memory and return to you the address of the first.
如果你运行了很多程序,假使用户复制粘贴了他们的论文,只是粘贴在光标提示符那里,这样就出现了内存不足,因为你们的计算机的内存是有限的,所以GetString不可能返回所有的字符,或者保存这些字符到内存中,并且返回第一个字符的地址。
应用推荐