C Arrays and Pointers to Pointers

  Рет қаралды 17,368

Kris Jordan

Kris Jordan

Күн бұрын

Пікірлер: 14
@davidkim7135
@davidkim7135 8 ай бұрын
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
@avixx
@avixx 2 ай бұрын
You're doin' good job!
@collin8096
@collin8096 Жыл бұрын
This was so helpful and helped me complete a lab. Thanks.
@neuodev
@neuodev Жыл бұрын
Great job explaning pointers 👍
@salmankhadour2581
@salmankhadour2581 2 жыл бұрын
such a good explanation, very thankful for u
@samuelkassahun9644
@samuelkassahun9644 Жыл бұрын
Thank you boss!.
@GCAGATGAGTTAGCAAGA
@GCAGATGAGTTAGCAAGA 2 ай бұрын
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 2 жыл бұрын
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 2 жыл бұрын
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 2 жыл бұрын
@@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 2 жыл бұрын
@@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.
array vs &array Pointers Difference Explained | C Programming Tutorial
17:38
ЧУТЬ НЕ УТОНУЛ #shorts
00:27
Паша Осадчий
Рет қаралды 10 МЛН
Sigma Kid Hair #funny #sigma #comedy
00:33
CRAZY GREAPA
Рет қаралды 39 МЛН
Pleased the disabled person! #shorts
00:43
Dimon Markov
Рет қаралды 30 МЛН
Alex hid in the closet #shorts
00:14
Mihdens
Рет қаралды 17 МЛН
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 293 М.
Fixed and Variable Length Arrays in C and C++
20:24
Jacob Sorber
Рет қаралды 43 М.
why do void* pointers even exist?
8:17
Low Level Learning
Рет қаралды 344 М.
C++ Pointers to Pointers - Finally Understand Double Pointers
13:18
you will never ask about pointers again after watching this video
8:03
Low Level Learning
Рет қаралды 2,1 МЛН
Arrays as function parameters in C
13:28
CodeVault
Рет қаралды 12 М.
Function Pointers | C Programming Tutorial
18:31
Portfolio Courses
Рет қаралды 58 М.
Double Pointers in C
10:20
Logic Lambda
Рет қаралды 3,7 М.
What are double pointers in C?
14:43
CodeVault
Рет қаралды 42 М.
Rust and RAII Memory Management - Computerphile
24:22
Computerphile
Рет қаралды 222 М.
ЧУТЬ НЕ УТОНУЛ #shorts
00:27
Паша Осадчий
Рет қаралды 10 МЛН