We'd expect you to write now or perhaps ever since this program was written as part of an obfuscated C contest.
我希望你们现在就开始写程序,否则你们将会在C语言比赛中,写得非常糟糕。
In Scratch, the block you may have used for this idea literally says "or" for or; in C, two vertical bars.
在Scratch中,这个你用的程序块,照字面地想法来说“or“表示或者;,在C语言中,是两个竖线。
And there is no programming language that is better well actually, that's not quite true, there are some better at doing certain kinds of things but there's nothing that you can do in C that you can't do in Fortran.
没有一种编程语言是更优秀的,当然实际上,这并不是完全对的,在做某些事儿时一些语言会更好用,但是没有事情是你能在C语言中做,而不能在Fortran中做的。
Today, I'm gonna start writing C code with you but I can't just write it and expect it to do anything.
现在,我和大家一起写C语言代码,但我不指望写出来后就能跑起来。
Short answer: no, at least not in C. You can construct such constructs in other languages and in theory even C.
简单回答:没有,至少在C语言里是没有的,你可以,在C语言或其他语言中创建这样一个结构体。
Realize in programming languages like C, there is a set of very well-defined rules, and this is in the recommended books.
同样,在像C语言这样的编程语言里,也有,一套非常明确的规则,这些都在推荐图书里面。
the choice of indentation here is deliberate throughout programming whether it's in C or PHP or JavaScript in this particular course.
不管是C,PHP还是JavaScript语言,通过缩进一些,程序块是有目的的。
This backlash N, it's also a recurring theme and not just in C but in PHP, JavaScript, other languages as well.
还有反斜杠n,不仅C语言里有,在其他语言像PHP,JavaScript等都会碰到。
So it turns out that, main, yes, is the default function you write, at least in C, when writing a program.
结果是,main函数,是的,这是你写的默认函数,至少是在C语言中,当写程序的时候。
So we are actually using the C99 version of C, which really means nothing useful today other than to realize we are using that version.
所以我们在使用的C语言的C99版本,这对今天来说是没多大用处的,只是告诉我们使用的是那个版本而已。
String is actually not a data type in C. It actually is something called a char star and we'll come back to this before long.
字符串在C语言里其实不是一种数据类型,而是一种称为char,*的数据类型,这个知识点我以后会讲到。
It turns out that in a lot of languages, C included, you the programmer knowing a bit about how the computer works and the language works, can exercise more fine-grained control.
结果在包括C语言的很多语言当中,你作为一个程序员懂得了一些计算机的工作方式,和语言的处理方式,可以更精确地控制运用它。
But to translate this now to a language C, you've got some curly braces, you got an if, some parentheses, but now we're just building on some of the syntax we introduced before.
如果把它转换成C语言,你又会看到一些大括号啊,if啊,圆括号啊等等,我们只是借助,之前学过的语法规则。
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语言写的。
Pseudocode is kind of an English-like syntax that's just a useful way of expressing yourself fairly succinctly, fairly computer-like but without having to worry about stupid details like whether it's Java or C or whatever.
伪码是一种类似英语的语法,可以简洁地,表达自己的意思,它与电脑类似,但是你不用担心那些愚蠢的细节,比如Java,C语言或者其他什么语言。
And generally in this language called "C" as well as a lot of others, almost all of your lines have to end with semicolons, but not all; just almost all and we'll see the difference.
通常在这个“C“语言中,像其他的语言一样,几乎所有的你们的代码行都要以分号结束,但不是所有的,只是大部分的,我们将看到他们的区别。
Well, it turns out C, like a lot of languages, comes out of the box with a whole bunch of built-in variable types.
在C语言还有其他一些编程语言里,都会有一大堆,固定的变量类型。
> What exactly is the difference with this system that we have here of compiling and say another compiler for one like the C++?
>在这个系统上编译,跟在我们这编译有什么不同吗?,也就是说,有没有其他的编译器供C++等语言使用?
So it turns out in C, you can absolutely represent the idea of a condition, a branch, a fork in the road.
结果在C语言中,你们完全可以表示出环境的概念,一个分支,一个三岔路口。
It's just some bogus language we made up that's kind of English-like, kind of look C-like now that you've seen this syntax, but it was just an arbitrary language.
并不是真正的编程语言,好比某种“伪英语“,或“类C语言“,你现在在语法中看到的就是所谓的伪代码,非常随意。
In C and most programming languages, if you need greater than or equal to, use greater than and then right next to it with no space put equal to, and that conjures up the same idea.
在C和大部分的编程语言中,如果你需要表示大于等于,在“>“号后边加上一个“=“,中间不要空格,那使我们联想到同样的想法。
Well, unfortunately in C, you have to be ever so specific as to what you wanna put in the variable.
很不幸,在C语言里,给变量赋值之前,你必须搞清楚它的数据类型。
So C or the compiler's for C are kind of dumb, by definition of the language years ago, whereby, they only know about what they've already seen.
所以C或者C的编译器是有点愚蠢的,根据多年前这个语言的定义,凭借那个,他们只知道,他们所看到的。
Well in C and many similar languages, you have to implement that same bracing structure with your keyboard using an open curly brace and a closed curly brace, so a tiny little detail.
在C语言和一些类似的编程语言中,你也必须搭建同样的架构,同样也得注意前大括号啊,后大括号啊等等这些细节问题。
Well in C and other languages that we'll see this semester, you use what's called the for loop, and this as syntax isn't quite as straightforward but once you know what to look for, it's very easy to understand.
在C语言和一些我们这学期将要接触的编程语言中,你将会用到所谓的for循环,也许作为一种语法规则,它看起来不是那么的通俗易懂,但是你一旦知道曲中奥妙,就不难理解了。
This two is from that obfuscated C contest so this is not where we're going but this is where some people choose to go.
这个就是那个很混乱的C语言比赛,这并不是我们要去的比赛,你们可以根据爱好决定参不参加。
In C, the truly correct way is to be very pathantic and say, ; nothing is coming into this function; void so I'll explicitly say, void here.
在C语言中,正确的方法是说明,没有任何东西进入到这个函数中来;,所以我明确地在这里指明。
The curly braces are then the C's way of kind of making a puzzle piece that looks like this so you can put stuff inside.
花括号是C语言的一个方式,用来做一个像这样的程序块,所以你可以把代码写在里面。
So here's where C differs from some language that you might be familiar with and from languages that you'll see later in the course, JavaScript like PHP and JavaScript.
这就是C与其它一些语言的不同之处,比如你熟悉的语言和,你们将在课程上看到的其它语言,像PHP和。
With C you can just line everything up on the left here because it's just text.
用C语言,你只要把代码排在这里的左边,因为只是文本。
应用推荐