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