foo You probably weren't calling foo ad nauseam here but segmentation fault refers to segments of memory colliding.
你可能不会倒胃口地调用,但是段错误是涉及内存段冲突。
foo Well, let's make this more interesting, foo.
好的,让我们把它变得更有趣点。
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,这些变量都是,函数的参数,在内存中存储。
bug Now, this was not the bug in this program because I did, in fact, use the equality operator and so it feels like if I type the word foo both times I should, in fact, get back you type the same thing.
现在,在这个程序中这个不是,因为,实际上,我使用了等于号,如果我输入单词foo两次,我返回给你“输入了相同的东西“
foo So everything is literally going back to back to back and so foo, similarly, if you have any local variables, like temp, it then goes here.
所以所有东西都背靠背紧邻着,所以对于,类似的,如果你有任何局部变量,像temp,它前进到这里。
So, I'm going to type foo enter, foo enter and I type different things. All right.
我输入foo,回车,foo,回车,我输入不同的东西,好的。
So pictorially, you can imagine foo getting called and then it finishes running; so these rows in this chart will just be whisked away.
看起来,你可以想象foo被调用,然后它结束运行,所以这个图表中的这些行,将被快速移去。
Right. So main calls foo, foo is declared, but wait a minute, void foo void I need my prototype; so void foo, void.
对,main调用foo,foo被声明了,但是等一等,我需要我的原型,所以。
foo Well, if main has any local variables X or Y or temp or foo or bar, or whatever the case may be, those variables come next in memory.
好的,如果main函数有本地的变量X或Y或temp或,或bar,或者诸如此类的例子,这些变量在内存中紧随其后。
It's being handed a picture that looks like this, and inside each baz of these squares is a word foo and bar and baz as well as the program's name.
它传递一个像这样的图画,在每个,长方形中是一个单词foo和bar和,还有程序的名字。
void Now there's a whole lot of foo and a whole of void here, but this is consistent with the lessons thus far today.
现在这里有许多foo和许多,但是迄今,这个是与课程是一致的。
F-O-O in lowercase and, in fact, foo it is buggy because I typed lowercase F-O-O and FOO yet I get back capital F-O-O as both the original and the copy and that's simply because I haven't done this correctly.
小写的f-o-o,实际上,它是有bug的,因为我输入小写的,而我得到的原始的和拷贝的都是大写的,简单说,我处理错了。
Let's type in foo. All right, so looks good, right?
我输入Foo,好的,看起来不错,对不?
argv Recompile my program, and now rerun Arg V of foo and bar.
重新编译我的程序,现在返回foo和bar的。
void foo It's appropriate to make fun.
好的。,Void,foo。,All,right。,这个适合开玩笑。
You can call it foo if you want, but you shouldn't.
你也可以叫它为foo,但是你不应该这样做。
Well it's a stupid looking program, but because I had more new line characters, and because I was using percent C, for individual characters, one per line, now I'm seeing dot slash ARG V2, well, now if I go ahead and rerun this with foo, I get this effect as well.
这是一个看起来很笨的程序,但是因为我有更多的新行代码,因为我使用的是%c,为单个字符使用的,每一行一个,现在我看到的是,/argv2,好的,现在如果我继续用foo返回它,我产生了这样的效果。
f-o-o If I type foo, I'll get back F-O-O.
如果我键入foo,我将取回。
Suppose I type in the word foo, F-O-O.
假如我输入了单词foo,F-O-O。
bar Let's try foo and bar.
让我试一下foo和。
And, again, the rectangle represents your computer's RAM, the bottom represents the part of RAM that we generally call the stack, main conceptually ends up on the bottom of the stack followed foo by its local variables then the function say foo that it calls and on and on and on and up, but there is, in fact, something above all of this and we've seen this picture briefly and that's this thing called the heap.
再次,矩形表示的是计算机内存,底端表示内存的一部分,通常我们把它叫做堆栈,main函数在,堆栈的底端,之后是,它的局部变量,然后是它调用的函数,等等等等,但是那里有,实际上,在这个上面,我们粗略看看这个图画,这个东西叫做堆。
应用推荐