By putting it in a function bug if I find a bug and I change my program I can just run the function again.
把我输入的值放到一个函数里,如果以后我在程序中发现了一个,并对程序进行更改的话,我可以直接。
I want the function, which is a little tool, a line of code I can include in my own programs and generally those tools live in sections two or three of the manual.
我想要一个函数,那是一个小工具,在我程序中可以包含的一行代码,通常这些工具在手册的第二节,或第三节。
Same way that I have multiplication or division as a primitive, functions are going to give me, or somebody else who wrote them for me as part of a library, a new primitive that I'm going to be able to use.
我在用乘法或者除法当做原语,这些函数,或者别人写程序库中的函数,将会给我返回一个,我能使用的新原语。
And henceforth I'm gonna start calling these tools, these monickers that I can use as building blocks in my own program, it's gonna be called a function as we'll see.
从此以后,我将在我的程序里把这些工具,称为我们可以用来写代码的组件,在我自己的程序中,我们将了解到它被叫做为一个函数。
It's just reminiscent of a previous program 9 9 9 or a previous function the number 9, 9, 9 so what does that really mean?
它提醒之前的程序,或者之前的函数,那个数字,那其实表示的是什么呢?
I'm saying "here comes my main function; here comes the guts of my program."
我指明“这里是我的主函数;,这里是我的程序内容,“
So it turns out that, main, yes, is the default function you write, at least in C, when writing a program.
结果是,main函数,是的,这是你写的默认函数,至少是在C语言中,当写程序的时候。
But very soon will you find that if you're writing programs with lots and lots of functions, and some might call these, and these might call these, you can come up very soon with scenarios where you can not order them top to bottom, because everything is comingled, and there's a lot of cross talk among all of your functions.
但是不久后你们会发现你们写的程序中,有很多很多的函数,有的函数调用这些函数,这些函数又调用另外的函数,你不能用脚本,把它们从上到下排序,因为所有函数相互混合,在你的函数中也有很多交叉。
But long story short, if I want to use a function called sleep, -- the reason I, the programmer, knew to use that library -- -- that header at the top -- because it told me to in this little synopsis.
但长话短说,如果我想要用一个叫做sleep的功能,我作为程序员知道使用那个函数库-,上面的标题-,因为在这个小的大纲中它告诉我。
Well, what's nice about this program is that there's just one function, main, so we don't need to draw the stack and get things all complicated.
这个程序的优点是,这里只有一个函数main,这样我们就不需要,画出堆,也不用那么复杂。
But if you avoid all of these minutia and focus really just on the idea, it looks like what was a blue say block, a so called statement, is now going to be something called printf where the F happens to stand for formatted.
但是如果你抛开所有这些繁琐的细节,把注意力集中到,它的编程思想,那么它只不过一个蓝色的say程序块,是一个声明,即所谓的printf函数,其中的f是,用于格式化输出。
应用推荐