Making Peace with Double Pointers

preview_player
Показать описание
---

***

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:



***

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:

To Support the Channel:
+ like, subscribe, spread the word

Want me to review your code?

You can also find more info about code reviews here.
Рекомендации по теме
Комментарии
Автор

3:39 `char *str;` is actually a pointer to a single character.

Marco-yjgg
Автор

Man it's so cool! Learning more about C makes me understand higher-level languages better. For example, nesting objects into arrays into objects etc. seemed like a magic in JS, but now it's clearly just stacking pointers under the hood! 🤯

nabiisakhanov
Автор

2:50 That short explanation just saved me a lot of brain cells. Thx so much.

mixed
Автор

Another use case I see is when you want to know what's in front of you but also where you came from. For example using a double pointer to traverse a linked list. Say we want to add an element in alphabetical order to our list. When can attach our double pointer to any of the links. This allows us to peak at the next element we are pointing at to check if the item we are inserting is going in the right place. If the next element is further in the alphabet all we need to do is deference our double pointer and attach the new element at our current memory address as our double pointer was in the correct address for the insertion. If I'm not mistaken this is how lists are handled in linux!

msk
Автор

Where were you all my life dude you cleared a major confusion i have been having in pointers.you deserve more attention for the quality of your content .thanks alot for this video

mathew
Автор

typedef can be your friend when dealing with triple or quadruple pointers. I just had to make a triple pointer in a project wherei had an array of pointers and i wanted to have a function that populates this array - naturally ending up with populate(type*** list) as an argument in my function. While this compiles and works without issue it is still hard to read so i used typedef type** typeList which reduced the argument to a single pointer again: populate(typeList* list)

I think this very handy in keeping the intention of the code clear instead of asking why there are three goddamn astrisks.

sschulze
Автор

1:04 example **p2=5 leads to segmentation fault, correction define a new variable int x=5 then assign x address pointer to *p2=&x

neroabey
Автор

I did get double pointers when i learned references in c++. double pointers are used as a reference of a pointer in c. Or iterating through matrix. But when people use arrays or matrix they really should use the [] operator instead of * to do dereferencing in my opinion. The programmers mind is more trained with this notation because of other languages.

xCwieCHRISx
Автор

Another thing about what the type to a pointer does besides telling the compiler what type to return when dereferencing is it says how many bytes to increment at a time. For example a char* ptr, would increment by 1 byte from the Base address of ptr if you increment it but the int* ptr would jump 4 bytes for each increment. It jumps sizeof(what ever its type) bytes from its current location in address.

Psykorr
Автор

Clearest explanation I've found, thanks!

Snydo
Автор

I haven't watched this yet, I wanna see your solution.
I once had a need for a 5th level pointer (long story!) I asked a friend that taught C @ UCSC. It stumped her and I have forgotten my solution! That was 30+ years ago!
The use of and ability to manipulate pointers is one of the most useful aspect of C to me.
Thanks for the pointers (no pun intended!) and tips on C. I'm picking it back up, after 25 years of no programming.
Ok, watched it. I think the problem was the compiler I was using, Microsoft C. It would choke at 5 levels of indirection, handled 4 levels just fine.
Compilers have come along way in 30 years!
Can't remember needing that deep indirection with gcc.

brucelytle
Автор

I'm totally losing it even looking at a single pointer. I can't really wrap my mind around the concept of a pointer.

peacemekka
Автор

Thanks for explaining the pthread_join example, that was very helpful!

jackdeansmith
Автор

Fantastic lecture, Jacob, thanks. A small bit of feedback -- during times like 00:36, could you vocalize more what "this... and this" are (pretend the audience were somewhat vision impaired). My favorite YT programming talks are the kind I can just "listen" to (podcast style) in the shower or when driving. (I'd also imagine the extra identification of key points would lend some accessibility boost to others as well)

thisisreallyme
Автор

0:45 Shouldn't the address of the integer pointer be 0x006AC instead of 0x006AD? Since char is one byte, therefore 0x006AB + 1 is equal to 0x006AC.
Please correct me if I am wrong. BTW, thanks for all your hard work. You don't realize how much your channel has helped me. God bless!

tonychan
Автор

I tried to look through internet but I couldn't find any easy example of double pointer used in 2D array. They just say "You can use it there" but don't show how

realdragon
Автор

It's not so much the concept of double pointers that's difficult...it's understanding the right syntax to make them do what you want...

bettyswunghole
Автор

*WHY would char** point to a 2D array? Can explain the logic in that? That wasn't explained in that video.*

OMNI_INFINITY
Автор

this video helped me to better understand double pointers !! i hope that make a video about using them in linked lists

mmkvhornet
Автор

used to make dynamic 2 dimensional array

tattikhatti
visit shbcf.ru