• s1 I have a variable called s1 and it's char * of type char * so here we go.

    我有一个变量,它的类型是。

    哈佛公开课 - 计算机科学课程节选

  • char* Because I've said that char Star is really just the true version of this.

    因为我说过,实际上是字符串的真实版本。

    哈佛公开课 - 计算机科学课程节选

  • char * s1 Then I go ahead and declare a char * called s1.

    然后我声明。

    哈佛公开课 - 计算机科学课程节选

  • So for now assume it's got to be an int or a char.

    所以现在假使它是一个整数或字符。

    哈佛公开课 - 计算机科学课程节选

  • So, should I be drawing these boxes four times bigger since ints are four times bigger than chars usually?

    所以,我应该把这个盒子画成4倍大,因为一般int型是char型的4倍大小?

    哈佛公开课 - 计算机科学课程节选

  • char *s2 = s1 >> David: Correct, yep, char *s2 gets s1.

    >,大卫:正确的,是。

    哈佛公开课 - 计算机科学课程节选

  • But a char we've seen, a character being a single character.

    正如我们看到的,一个字符就是一个单独的字符。

    哈佛公开课 - 计算机科学课程节选

  • char *s2 = s1 It's char * s2 gets s1.

    就是。

    哈佛公开课 - 计算机科学课程节选

  • 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,*的数据类型,这个知识点我以后会讲到。

    哈佛公开课 - 计算机科学课程节选

  • I get the int and store it in n. The switch statement takes inside its parenthesis an int or a char or some primitive type.

    我得到一个整数并把它存储,到n中,switch语句的圆括号里可以是一个整数,或者一个字符或其他的基本类型。

    哈佛公开课 - 计算机科学课程节选

  • So here is one of the interesting takeaways, a char, we've already spoiled this answer, takes up how many bits.

    关于char还有一个重点:一个char占据多大内存,这个问题我们已经翻来覆去说了好多遍了。

    哈佛公开课 - 计算机科学课程节选

  • char Here is the char, here is the char, how many bits did we say each of these squares is?

    这是一个char,这是一个,那么这里的一个方框几比特呢?

    哈佛公开课 - 计算机科学课程节选

  • So if you've ever seen or used an old school typewriter, you might recall that when you're typing something out on an old mechanical typewriter, - when you like hit the char-- when you hit the enter key to move the head back to the left hand side to the next line or you would pull down some lever, it was really a two part process.

    如果你们有谁曾经看过或用过老式打字机,可能还记得,当你在,这种老式打字机上打字的时候,当你-,敲入回车键,跳转到,下一行的最左边,或者,拉一下杆,这个需要两步走。

    哈佛公开课 - 计算机科学课程节选

  • This is convention, so on almost-- and most any computer you overuse, if you're writing code that uses a char, you're gonna be handed 8 bits or 1 byte to store that particular char.

    这是约定,对于大多数-,电脑,当你写代码要用到一个char型数据时,必须先预留8比特或1字节,的空间来存储这个char型数据。

    哈佛公开课 - 计算机科学课程节选

  • - We know from Wednesday if -- briefly -- that there's this thing called a "char" or "char," depending on how you want to pronounce it, which is just a single character but where there's also an int.

    我们知道从周三起--简单说下-,我们有个叫做“char“或“char“,看你们怎么读它了,那代表一个单一的字符,但那里会有个整型数与之对应。

    哈佛公开课 - 计算机科学课程节选

  • Is there a key word like int or char double with which you can represent a 1024-bit value?

    有一个像int,char,double这样的关键字,用来表示一个1024位大小的数值呢?

    哈佛公开课 - 计算机科学课程节选

  • y A square it's called X, another square it's called y and now this time I'm doing pointers to int not points to char.

    一个叫做x,另外一个叫做,这一次是int型指针,不是char型指针。

    哈佛公开课 - 计算机科学课程节选

  • Now, I've taken off the training wheel of the CS50 Library and I'm just flat out saying char *. No more strings.

    现在,我开始了CS50库的培训,我只指明char,*,没有更多的字符串。

    哈佛公开课 - 计算机科学课程节选

  • And so if we wanted to do this here, it's again, the same thing we're just now pulling back this layer and calling them char *s not actually strings.

    如果我们想要在这里这样做,再次,我们撤销这一层,把它们叫做char,*s,实际上不是字符串。

    哈佛公开课 - 计算机科学课程节选

  • When you declare a pointer yourself manually, you do say char * the variable name because recall that's the same thing that we did earlier but we called it instead string.

    当你手动声明一个指针是,你可以说char,*,变量名字,因为那是我早些时候做的事情,但是我们叫它为字符串。

    哈佛公开课 - 计算机科学课程节选

  • This is copy2.c. At the very beginning I, again, demand say something and then I declare s1 to be a string, aka char *, and I store in s1 the string the user types in.

    这是copy2。c,在开头打印一句话,然后声明s1是一个字符串,也叫做char,*,然后把用户输入的字符串存储在s1中。

    哈佛公开课 - 计算机科学课程节选

  • If you want to do the opposite process, you simply "cast to an int from a char."

    如果你想做相反的转换,你就告诉计算机,“把那个char型数据转换成int型处理“

    哈佛公开课 - 计算机科学课程节选

  • We did it for silly purposes just to see how big each data type was, but on most systems the size of a char is what?

    只是为了很傻的目的,来看看每个数据类型多大,但是在大多数的系统中char的大小是多少呢?

    哈佛公开课 - 计算机科学课程节选

  • char * and frankly this is why we hide this detail in the first week or two because it's just not interesting to get into that early.

    所以一直以来,char,*。,So,all,this,time,这就是为什么在第一二周我们隐藏这个细节的原因,过早的深入这个,是没有好处的。

    哈佛公开课 - 计算机科学课程节选

  • So, after the second line for code here char * s1 gets the return value of get string this is what the state of our world looks like.

    在第二行之后,这个代码char,*s1,等于GetSting的返回值,这就是它看起来的状态。

    哈佛公开课 - 计算机科学课程节选

  • A If you want to convert a number like 65 to the letter A, you just have tell the computer "cast that int to a char."

    如果你要把一个像65这样的数字转换为字母,你只需要告诉计算机“把那个int型数据转换成char型处理“

    哈佛公开课 - 计算机科学课程节选

  • int No. Even though the key word has changed from char to int, the * is the same and the fact that I've got a * there is saying this is a pointer to an int or a pointer to a char pointers are always the same size on a computer.

    不,即使即使关键字从char变成了,指针的大小还是一样的,我用*表示这是一个int型指针,而不是char型指针,在同一台机子上,它们的大小是一样的。

    哈佛公开课 - 计算机科学课程节选

  • So a char is one byte, which is bits -- how many?

    所以char类型占了1个字节,--那是多少位?

    哈佛公开课 - 计算机科学课程节选

  • So a char size is 1 byte or 8 bits.

    一个char型数据占据1字节或8比特。

    哈佛公开课 - 计算机科学课程节选

  • So it's an address, it's a pointer, address pointer, synonyms for now, so it's the address of a char so this makes sense because s1 is also the address of a char so if I wanted to make a copy of that address this is absolutely the right syntax.

    是一个地址,是一个指针,地址指针,也就是,char型数据的地址,这是有意义的,因为s1也是一个char型数据的地址,所以如果我想要复制那个地址,这个绝对是正确的语法。

    哈佛公开课 - 计算机科学课程节选

$firstVoiceSent
- 来自原声例句
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定