So, at the very top of the file I'm just copying and pasting what was essentially on the slide a moment ago.
在这个文件的顶端,我只是做了复制和传递。
And, it's also, I think they keep in on file.
还有,我想这个还会记录在档案里。
This is a little file I created, all right, and I'm going to start with a sequence of these things and walk them along, again I invite you to put comments on that handout so that you can follow what we're going to do. All right?
这是我创建的一个小文件,好,然后我回去以一系列这样的事情,开始然后进行下去,我还是想大家都在手册上做一些注释,这样我们就能对将要做的事情,做一个记录了,对不对?
stdio c So somewhere there's standard IO dot C, stdio h somewhere they're standard IO dot H, but, for me, right now, the only file I need to know about is the dot H, -- because what Sharp include really does -- it's what's called a preprocessor directive.
所以某个地方有一个,现在对于我来说它们是,我只要知道那个,h文件,因为Sharp包含的-,叫做预处理指令。
Right now, I have to take that piece of code and replicate it everywhere I want in my larger file.
现在我要把这段代码,复制到,大文件中的各个部分。
When I said in Week One that you don't actually have zeros and ones inside this header file; right?
在第一周我说过的,我们在这个头文件中,是没有二进制的,是吗?
For some reason, at the top of this file, I've also included what I've called a function prototype.
因为一些原因,在这个文件顶端,我包含了一个函数原型。
It's instead outside of them and, by convention, at the top of the file so that I can access it anywhere, whether or not this is a good thing, remains to be seen.
它在函数的外面,按照惯例,在文件的顶端,所以我可以在任何地方使用它,不管这是不是好事情,拭目以待。
Well, I include what's called a header file as we'll call it.
好吧,我需要包含一个头文件。
stdio h This file here is called standard I/O or stdio.h and this is just another text file someone else wrote many years ago and by using that line of code there, I'm telling the computer, give me acces to this code that this other person wrote that's in that file.
在这里的头文件称为标准输入输出文件或,这是由某位前人编写的文本文件,我们只需要刚才所述的一行代码,就能告诉电脑,让我连接到,这个前人在那个文件中写的代码。
So that's why I've included that header file.
这就是我包含那个头文件的原因。
So I could -- and the hint here is that looks like you probably do want to use CS50's library because I've included the so-called header file for it.
所以我可以--这里的提示看起来好像,你可能的确想使用CS50的函数库,因为我包含了所谓的头文件。
Make then assumes I'm in a file called make math2.c and goes and finds it.
假设我在一个叫做“make,math2,c“的文件里,然后去找它。
So I'm saving this file, notice there is a few keywords that we'll come back to next week like main which is kind of the main part of my program.
保存此文件,注意这有几个关键字,我们在下周介绍,比如代表程序主体部分的“main“
LS And what very often happens if you do an LS in your account, to list your files, there's a whole lot of stuff in here at the moment -- and I don't have it here - but what you'll often see -- I'll just fake this demo -- is a file called core.
经常发生的是,如果你用你的账号做一个,来列出你的文件,此刻这里有一大堆元素,-它不在这里,但你们将经常看到--我将篡改这个演示-,是一个叫做core的文件。
So if I open this file, notice I just did "%d."
所以如果我打开这个文件,请注意我这里有“%d“
As I said, right now that's just text file.
正想我刚才说的,它现在就是一个文本文件。
I like it at the top of my file.
我喜欢把它放到我文件的顶端。
This is a keyword to Python that says, when it reads this in the file, it says, I'm creating a definition.
这是Python语言的关键词,当你在文件中读到这个词的时候,它的意思就是我正在创建一个定义。
So I'm gonna go ahead and save this file, hello c it's hello.c, dot C hints at the fact that this program I just whipped up is written in a language called C.
所以我打算继续,保存,并命名为,“,c“表明这个程序,是使用C语言写的。
It makes sense to me logically that I want to see it first when I open the file; so I scroll on down but only later is increment declared.
这个逻辑上对我是有意义的,打开文件的时候,我想先看到它,所以我向下翻,之后才声明increment函数。
I'm gonna call my file hello.c. There's a little bit GUI-- of distraction here but this is because this is not a GUI, CLI a graphical user interface, this is a CLI, command-line interface, which just means there are no windows and icons.
我先给我的文件命名为“hello,c“,你们也许会觉得有点烦,因为不是,图形用户界面,这是,命令行界面,这意味着没有窗口,没有图标。
Why is this much nice? Well, that's a handy piece of code. Because imagine I've got that now, and I can now store that away in some file name, input dot p y, and import into every one of my procedure functions, pardon me, my files of procedures, because it's a standard way of now giving me the input.
为什么这样很好呢?,这是一段很好用的代码,因为想象下如果我有了这段代码,我能把它用某个文件名保存起来,后缀是。py,导入到所有的处理函数中,抱歉,我的处理文件,因为这是一个标准的输入方法。
应用推荐