s1 I have a variable called s1 and it's char * of type char * so here we go.
我有一个变量,它的类型是。
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.
所以现在假使它是一个整数或字符。
But a char we've seen, a character being a single character.
正如我们看到的,一个字符就是一个单独的字符。
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占据多大内存,这个问题我们已经翻来覆去说了好多遍了。
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位大小的数值呢?
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的大小是多少呢?
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型数据的地址,所以如果我想要复制那个地址,这个绝对是正确的语法。
应用推荐