C Arrays and Pointers to Pointers

  Рет қаралды 18,183

Kris Jordan

Kris Jordan

Күн бұрын

Пікірлер: 14
@davidkim7135
@davidkim7135 11 ай бұрын
Best explanation of a pointer to a pointer. I finally understand what it means. Thank you Mr. Jordan!!
@grimvian
@grimvian Жыл бұрын
Exellent pedagogical instructor - top class. I consider myself at medium level. I'm writing C code at regular basis, but Kris is closing the the little holes in my knowlegde here and there. Strange that Kris don't have more subscribers.
@venonnegru
@venonnegru 2 жыл бұрын
Interesting! I had learned C in school but I never imagined that arrays in C is so complex coz Java ran over this language in class. I'm a Java programmer for the last 17 years and python now and it's so common to work with these types that when you step back to C, man, I got confused LOL Back to basis
@neuodev
@neuodev 2 жыл бұрын
Great job explaning pointers 👍
@collin8096
@collin8096 2 жыл бұрын
This was so helpful and helped me complete a lab. Thanks.
@samuelkassahun9644
@samuelkassahun9644 Жыл бұрын
Thank you boss!.
@avixx
@avixx 5 ай бұрын
You're doin' good job!
@salmankhadour2581
@salmankhadour2581 2 жыл бұрын
such a good explanation, very thankful for u
@GCAGATGAGTTAGCAAGA
@GCAGATGAGTTAGCAAGA 5 ай бұрын
Great tutorials! But, I've got really stupid question: 33:00 - if we increment *words pointer it would have the same effect as incrementing **word_ptr, right? It does "switch" to the next address or will it become just garbage?
@johnnyappleprng614
@johnnyappleprng614 3 жыл бұрын
Wait a minute! What was sizeof words? 3? (around minute 30 ... you asked us and then never explicitly answered I don't think... typing it out in vim now!) EDIT: Oh geez... apparently the sizeof(words) is 24? How does that happen? sizeof(a) is 2, sizeof(b) is 4, and sizeof(c) is 5. 5 + 4 + 2 = 11 ... and then you + 1 and * 2 for some reason after that??? EDIT2: Ok I think I get it... Since a is essentially &a and &a is 8 characters long... 8 * 3 elements in words = 24 bytes in total correct? :S Great video by the way!
@lilyscarlet2584
@lilyscarlet2584 3 жыл бұрын
it gives the size of the type it has nothing to do with the value. int x = 20; sizeof(x) will return 4 bytes assuming int is 4 bytes. sizeof(int) is the exact same. if you have an array of 4 ints the size of the array would be 16 bytes. in the case of char it would just be 1 byte per element so the size of the array would also be the number of elements. remember it returns the size in bytes so if i have 4 integers in my integer array i can do sizeof(array) / sizeof(type) which will return the number of elements total. 16 / 4 = 4 integers.
@flyingmadpakke
@flyingmadpakke 3 жыл бұрын
The fact that you get 24 tells me that you have a 64 bit system, here is why: Words is an array of pointers to a char. That is 3 pointers in this case. Therefore the total size of words is the size of 3 pointers to chars. Because pointers are memory addresses, it doesn't actually matter what they point to when we evaluate their size - While the values stored at that address may have different size, it doesn't matter if I give you the memory address to a char, int, short, long etc., the address number itself (the hexadecimal) has the same size. For a 64 bit system, the addresses are 64 bit in length, which is 8 bytes. So 3 addresses is 3*8 = 24 bytes. If you compile that code on a 32 bit system, the length of words would be half that, because then addresses are only 4 bytes.
@lilyscarlet2584
@lilyscarlet2584 3 жыл бұрын
@@flyingmadpakke the type just tells you how many bytes taken up as well as the format. int and float assuming both 4 bytes take up the same memory but have different formats. a short assuming 2 bytes would be 2 memory addresses but the pointer is always to the base address which depends if the address mode is 32 bit or whatnot. 32 bits is 2^32 addresses or 8 hex digits. types have nothing to do with memory locations therefore pointers dont have types its just how should the data at that address should be interpreted and where does the next value start whether it be 2 or 4 bytes away or whatever. if you reinterpret data as a different type by casting to say char* it will only look at the first byte.
@flyingmadpakke
@flyingmadpakke 3 жыл бұрын
@@lilyscarlet2584 I agree with you. This is what I meant by saying it doesn't matter what type the pointer is pointing to because the pointer itself is ultimately a memory address, which is a number that is always the same size on your system, either 32 or 64 bits. For example, on my system I get sizeof(void*) = 8 and printing my addresses gives me 16 hex digits, because I have a 64 bit system. I actually don't know if some systems store more (or less) than 1 byte pr. address. As pointer increment has correlated 1:1 with byte size of types as far as I have seen, i.e. incrementing the pointer of an int increments the address by 4, this seems to be common, but maybe other memory implementations exists.
Introducing Pointers and the Address Of Operator in C
52:08
Kris Jordan
Рет қаралды 8 М.
MY HEIGHT vs MrBEAST CREW 🙈📏
00:22
Celine Dept
Рет қаралды 105 МЛН
MAGIC TIME ​⁠@Whoispelagheya
00:28
MasomkaMagic
Рет қаралды 37 МЛН
ПРЯМОЙ ЭФИР. Золотой мяч France Football 2024
4:41:06
这是自救的好办法 #路飞#海贼王
00:43
路飞与唐舞桐
Рет қаралды 96 МЛН
Design Principles with Pointer Parameters and Functions
41:17
Kris Jordan
Рет қаралды 9 М.
What are double pointers in C?
14:43
CodeVault
Рет қаралды 44 М.
Pointers in C for Absolute Beginners - Full Course
2:04:29
freeCodeCamp.org
Рет қаралды 240 М.
ARRAYLIST VS LINKEDLIST
21:20
Core Dumped
Рет қаралды 72 М.
Dynamic Memory Allocation | C Programming Tutorial
31:51
Portfolio Courses
Рет қаралды 88 М.
MY HEIGHT vs MrBEAST CREW 🙈📏
00:22
Celine Dept
Рет қаралды 105 МЛН