Right now, I have to take that piece of code and replicate it everywhere I want in my larger file.
现在我要把这段代码,复制到,大文件中的各个部分。
And, it's also, I think they keep in on file.
还有,我想这个还会记录在档案里。
stdio h It pretty much means open this file, standard IO dot H and just paste its contents right here.
它的大致上的意思是打开这个文件,然后把它的内容粘贴在那里。
Right now, you've got to write it in one file.
现在,你可以把它写在一个文件里。
You can put a variable there, and because it's not encapsulated in curly braces, as we just discussed, that essentially means it's accessible everywhere in that file.
你可以加入一个变量,因为它不是封装在花括号里,就像我们刚才讨论的,本质的意思是它可以在文件的所有地方,都可以被访问到。
When you're working on a file, it's saving constantly to RAM but also hopefully to disc, the hard disk so you don't actually lose it if the power goes off.
当你打开一个文件,它不断地保存在内存中,但对于光盘,硬盘,当你断开电源的时候,数据不会丢失。
So those are in fact the patterns of zeroes and ones, the bytes that would have been outputted had I hello c remembered to download the compiler to this computer and run it on that little hello.c file.
这些都是0和1的模式,如果我记得下载编译器到计算机上的话,我们就能运行下这个,然后看看输出的字节。
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.
好吧,我需要包含一个头文件。
It's in a file called swap.C. Everything should be alphabetical so it should be toward the end of this week's packet and notice that it's almost identical except for a couple of syntax changes.
在一个叫做swap。c的文件中,对于这周末的数据包来说,所有的东西都是字母,请注意,除了几个语法改变,它几乎是一样的。
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“的文件里,然后去找它。
In a .h file, it's generally the names of functions other people wrote.
在头文件里,只有一些函数名。
This is a keyword to Python that says, when it reads this in the file, it says, I'm creating a definition.
这是Python语言的关键词,当你在文件中读到这个词的时候,它的意思就是我正在创建一个定义。
I like it at the top of my file.
我喜欢把它放到我文件的顶端。
It was scoped to the whole file.
而是在整个文件的范围。
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 takes an int; deal with it when you get to it and then once you look through the whole file, should you find -- ultimately find the actual code that defines or impliments this thing.
它携带一个int数,当你获得了它就处理它,然后一旦你查看整个文件,最终你将发现实际代码中,定义或执行了这个东西。
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函数。
So it turns out a really nice shortcut on most systems, oops, is to say if you have a file called hello.c and you wanna turn it into a program called hello, well, make hello just write in the command makeHello and it will do all of that for you automatically and hand you a program called hello.
就是寻找一种能在大多数系统上运行的更快捷的方式,哇!,也就是说,你有一个hello,c的文件,你想把它变成一个名为hello的程序,那么只需要敲入命令,它就会自动为你生成,一个hello程序。
So among your printout from Wednesday, if you have it, you have a file called math1.c. If you don't have this, the programs are short today, so it should be easy enough to follow along visually, but a PDF and the actual source code is available online for these things.
从你们周三打印出来的资料来看,如果你们手上有的话,你们会看到有个叫做的“math1,c“的文件,如果你们没有资料,那些程序还是比较短的,所以你们应该可以很轻松地,来看这些程序,但是那个PDF文件,和实际的源代码都可以到网上找到,相关的资料。
应用推荐