1. Tubelator AI
  2. >
  3. Videos
  4. >
  5. Education
  6. >
  7. Arrays, Pointers, and Why Arrays Start at Zero?

Arrays, Pointers, and Why Arrays Start at Zero?

Available In Following Subtitles
Chinese
Variant 1
Posted on:
Video by: Jacob Sorber
Patreon ➤ https://www.patreon.com/jacobsorber Courses ➤ https://jacobsorber.thinkific.com Website ➤ https://www.jacobsorber.com --- *** Welcome! I post videos that help you learn to program and become a more confident software developer. I cover beginner-to-advanced systems topics ranging from network programming, threads, processes, operating systems, embedded systems and others. My goal is to help you get under-the-hood and better understand how computers work and how you can use them to become stronger students and more capable professional developers. About me: I'm a computer scientist, electrical engineer, researcher, and teacher. I specialize in embedded systems, mobile computing, sensor networks, and the Internet of Things. I teach systems and networking courses at Clemson University, where I also lead the PERSIST research lab. More about me and what I do: https://people.cs.clemson.edu/~jsorber/ http://persist.cs.clemson.edu/ *** Welcome! I post videos that help you learn to program and become a more confident software developer. I cover beginner-to-advanced systems topics ranging from network programming, threads, processes, operating systems, embedded systems and others. My goal is to help you get under-the-hood and better understand how computers work and how you can use them to become stronger students and more capable professional developers. About me: I'm a computer scientist, electrical engineer, researcher, and teacher. I specialize in embedded systems, mobile computing, sensor networks, and the Internet of Things. I teach systems and networking courses at Clemson University, where I also lead the PERSIST research lab. More about me and what I do: https://www.jacobsorber.com https://people.cs.clemson.edu/~jsorber/ http://persist.cs.clemson.edu/ To Support the Channel: + like, subscribe, spread the word + contribute via Patreon --- [https://www.patreon.com/jacobsorber] + rep the channel with nerdy merch --- [https://teespring.com/stores/jacob-sorbers-store] Source code is also available to Patreon supporters. --- [https://jsorber-youtube-source.herokuapp.com/] Want me to review your code? Email the code to [email protected]. Code should be simple and in one of the following languages: C, C++, python, java, ruby. You must be the author of the code and have rights to post it. Please include the following statement in your email: "I attest that this is my code, and I hereby give Jacob Sorber the right to use, review, post, comment on, and modify this code on his videos." You can also find more info about code reviews here. https://www.youtube.com/watch?v=k2K2HVg4Arc
tubelator logo

Instantly generate YouTube summary, transcript and subtitles!

chrome-icon Install Tubelator On Chrome

Video Summary & Chapters

No chapters for this video generated yet.

Video Transcript

0:00
好吧,让我们谈论序列和指标,以及为什么序列指数从零开始。
0:09
在我最近的关于类型的视频中,我谈论了阿里斯,我谈论了指标。
0:13
從我引導你們,從我所描述的方式,
0:17
你可能會感到,Arays和指標實際上對彼此無關。
0:22
他们不是那么类似的。
0:23
我想,一个集合就是一个集合物,
0:25
一个指标保持一个地址或位置在记忆中。
0:29
它们看起来很不同,但不是那么快。
0:31
因为它们实际上非常密切相关,并了解指标和序列之间的关系将使你成为一个更好的C程序员,一般来说,它只会做C。
0:40
那么,让我们从一个简单的例子程序开始吧。
0:45
它是非常简单的。它宣称5英寸的范围,并使它们初步到
0:49
数字 1, 2, 3, 4 和 5. 好吧,然后它打印它们。
0:53
我从0开始,我将到4开始,我有一个印刷声明。
0:57
对于每一个字符串的输入。现在让我们运行它。 你去那里。 你打印了 5
1:03
现在让我们添加一个名为P的指标,奇怪的是我们只能
1:10
把它分为 v. 现在我已经考虑了把整个教训当今,但然后我认为
1:15
这可能变得老了,你可能不会留下来。认真地,没有更多的节奏。因为你是超级的。
1:20
新到C,可能对你来说并不奇怪,我可以分配 p 到 v. 我只能分配
1:25
一个指标到一个系列,但它应该看起来有点奇怪,因为C通常很漂亮。
1:30
关于这种类型的事情,例如,说我试图分配 p 给一个 int. 好马上
1:35
编译器抱怨. 也就是说,你有一个 int,你正在试图将它分配到一个
1:39
指标和那些不兼容的类型,但它是好的,一个 int array。
1:45
因为,看起来很奇怪,从编译器的角度来看,p和v几乎是
1:50
同样的事情,让我看看我能说服你,好吧,说我想改变一个元素。
1:54
我可以用我的列表评分这样做。现在,类似,我可以做
1:59
同样的事情与p. 因此指标可以像序列一样运作。当我使用这些平方子时
2:03
使用指标,编译器只是将处理 p,就像存储的 int 序列。
2:08
在指标中包含的地址 p. 但序列可以像指标一样运作?好吧,让我们
2:13
首先,我想向您展示一些关于指标。指标算法。 指标算法。 显示
2:17
首先打印 p 的地址,然后打印 p 加上 2 的地址。
2:22
现在你可能认为这只是原始号码加上2,但不是。
2:27
这是我们打印的原始地址,加上8.但为什么?编译器正在做
2:32
在这里,它增加了指标点的物品的尺寸的2倍。
2:37
因此,在这种情况下,一个 int 长达 4 位,所以 p 加上 2 位增加 4 倍 2 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 位 。
2:45
因为指标基本上只是以不同的形式的序列,而C标准是设计的。
2:50
假设你将使用指标,就像序列一样,所以当我使用序列标记时
2:55
并说我想要分数p或指标pp的元素0,基本上是相同的。
3:01
这个,低指标指标,在前面粘着一个星球。 同样,我可以
3:06
接入元素 1 正如此,以及元素 2,在每个情况下,它基本上正在移动
3:13
地址由正确的字符数转移到列中的元素。
3:17
想要,然后它得到这个新地址指向的 int。
3:21
所以现在你理解指标算法,显然我们可以做同样的事情。
3:24
我们的阿拉伯。
3:25
我们可以使用指标算法访问V元素,因为V基本上几乎是
3:30
指标。
3:31
大家好,这就是为什么一系列的第一要素总是0而不是1的原因。
3:36
因为寻求一个系列的零元素实际上是寻求一个元素。
3:40
这是从这个序列开始的0个字节。
3:43
所以现在,我希望我说服你,指标和Ariys基本上是
3:47
同样的事情,让我们简短地谈论它们是如何稍微不同的。
shape-icon

Download extension to view full transcript.

chrome-icon Install Tubelator On Chrome