You honestly have a gift for teaching this stuff. Typecasting is an obtuse topic at times and a typecast pointer is very obtuse. I've never really understood them and how they are used, until now.
@PortfolioCourses Жыл бұрын
Thanks so much for the kind feedback Brian, and I'm glad the video was able to help clear that up for you! :-)
@naboulsikhalid7763 Жыл бұрын
when it's great, it is always great and always will be. The pointers were my roadblock until now, but things have become smoother and I can follow without fear. Thanks, Kevin, for the great effort which is priceless.
@siya.abc123 Жыл бұрын
Another complex topic explained simply. Thank you for all your teachings. Your teaching style is top tier
@PortfolioCourses Жыл бұрын
You're very welcome Siya, I'm glad you enjoy the videos! :-)
@tracetv8115 Жыл бұрын
I found ur videos about c and u are an absolute genius in explaining things! Thank u so much for ur content!
@Lichen1 Жыл бұрын
holy crap not to be weird but im high and i was literally just wondering about void pointers and your video just came out so this is great!! thank you!! also your tutorials are so helpful. i greatly value the knowledge you impart.
@PortfolioCourses Жыл бұрын
Hahaha I had a weird feeling that "today, I should make a video on void pointers", maybe it was destiny! :-) You're welcome Anthony, I'm really glad to hear you enjoy the tutorials.
@arthur_p_dent4282 Жыл бұрын
😂 cheers
@justcurious1940 Жыл бұрын
@@PortfolioCourses "Destiny is all " : Uhtred of Bebbanburg.
@justcurious1940 Жыл бұрын
Extensive explanation about this topic, Thanks Kevin.
@GianlucaSibaldiАй бұрын
Awesome tutorial! 😃 To be even less ambiguous I always prefer to attach the star to the type, I mean: int* p = &a instead of int *p =&a. This way in my opinion it’s very clear that the variable type is “int pointer”. And this way also you make a clear difference between the way you declare a pointer variable and the way you deference a pointer variable. Which I often noticed leads to some initial confusion at the early stages of understanding pointers.
@starc0w Жыл бұрын
I was curious if you will mention that pointer arithmetic on void pointers is illegal according to ISO C. You did mention it! Excellent tutorial! Thank you so much! If we don't need a cast after malloc in C, can we use the following syntax to keep the instruction more generic? int* ptr = malloc(n * sizeof(*ptr)); (No need to adjust the right side of the assignment if the pointer type of "ptr" should change). Is this legal according to ISO C? Would you do it the same way professor? Thank you very much!
@PortfolioCourses Жыл бұрын
You're welcome! I'm not sure if that's legal according to ISO C, though it seems to compile OK in gcc at least and I don't see why it would be illegal. I don't know if I would do it that way or not, I think if I was changing the type of 'ptr' anyways, then it might not be a big deal to change the sizeof() as well. On the other hand it's nice to only have to change one thing, so I think it may depend on the situation.
@starc0w Жыл бұрын
@@PortfolioCourses Ok! Thank you very much!👍
@PortfolioCourses Жыл бұрын
You're welcome! :-)
@starc0w Жыл бұрын
@@PortfolioCourses I found it in the Standard (the latest one). Page 82 (Not the PDF page, but the page number that the document itself lists). 6. 5. 3. 4 The sizeof and alignof operators Paragraph 6. I would like to post the link, but then KZbin deletes my post. There is also an example on "cppreference" in the chapter malloc.
@justcurious1940 Жыл бұрын
@@starc0w Yes I have seen examples like this on "cppreference" and according to ChatGPT the sizeof operator does not need to dereference ptr to determine its size, it only needs its type.
@LeFede Жыл бұрын
the GOAT in c
@goktugparlak1618 Жыл бұрын
Thank you so much for great explanation
@fifaham Жыл бұрын
Nice explanation, thank you Kevin.
@PortfolioCourses Жыл бұрын
I’m glad you enjoyed it Firas, and you’re welcome, I hope you are well! :-)
@parosdelos6914 Жыл бұрын
Would you mind making a playlist on all the pointer videos you've done so I can follow them chronologically?
@NikolaNevenov86 Жыл бұрын
To me the whole thing with pointers devolves to simply memory access. A type pointer will read the memory address depending on the type(int* will read 4 bytes and will decode the bits as int). A void pointer is a typeless pointer, it holds a memory address but does not know what is there. I think the fact that all pointers(regardless of type) are of the same size was a big eye opener to me. That being said, when we are moving the void pointer via pointer arithmetic, then the movement acts like that of the char* where each move is done in 1 byte * n . A type pointer will move depending on it's type, like a int* will move 4 bytes. Thus recently I wondered if there is any benefit to a void pointer since it acts like a char*. Of course one of the benefits is that it's typeless and thus can be a pointer to any type. Making it more universal.
@PortfolioCourses Жыл бұрын
I agree that the size of all pointers being the same is a big eye opener for people as to 'what pointers are really doing'. :-)
@MultiScott10007 ай бұрын
nice explanation. thanks.
@grimvian Жыл бұрын
Again, great video! I see the void pointer as a multi-type pointer with some restrictions. When I 'malloc' memory, I use the data type(s) to format the memory to the desired type in pedagogical way.
@PortfolioCourses Жыл бұрын
Thanks! :-) I always think of void pointers as something like "polymorphic behaviour" in C programming.
@grimvian Жыл бұрын
@@PortfolioCourses I think it's because you are an IT-professor and I'm absolutely not... :o) Your pedagical skills are also great and not many are capable of combining these two very diffrent tasks in a good way. I'm actually have dyslectic issues, but your very clear voice makes the learning much easier. Sorry for my English.
@arthur_p_dent4282 Жыл бұрын
Great stuff as always.
@PortfolioCourses Жыл бұрын
I'm glad you enjoyed it Arthur! :-)
@Joao-oo8yj6 ай бұрын
I did understand pretty well this thing about pointers... but I was wondering why the heck the function `qsort` you show in the video takes a pointer parameter which type is void*? `qsort` is gonna iterate over each contiguos address of the array, but how will it do that if the pointer type is void* which doesn't accept arithmetic operations?
@PortfolioCourses6 ай бұрын
You provide a function to qsort, and that function does the comparisons, typically using a typecast to convert from void * to something you can do comparisons with.
@eugenebespalov9471 Жыл бұрын
If I saw *((char *)p) before, I'd definitely freak out! Thanks for your videos, this is no longer the case.
@grimvian Жыл бұрын
Me too and the difference between making a pointer and get the value from a pointer.
@PortfolioCourses Жыл бұрын
You're welcome, I'm glad the video helped with that! :-)
@ozkanakbas4805 Жыл бұрын
hi can you make a video about serial communication in c?
@PortfolioCourses Жыл бұрын
I've never done serial communication before Ozkan, but thank you for the idea you never know maybe one day I can cover it, I'm looking into it now and it's interesting. :-)
@ozkanakbas4805 Жыл бұрын
@@PortfolioCourses 😁
@wlcrutch Жыл бұрын
Is it fair to say that, when you “p is pointing to a memory address if any type of data” for void *p that we could also say: “p is pointing to a memory address that can hold a data type of any size”? If I am thinking of a memory address (size depending on the hardware if course) then it is a series of bits that are either high or low…and the data type tells us (in addition to helping write correct programs) how many bits we can store there? or am I taking my microcontroller class (in assembly) too seriously? 😅
@otaxhu11 ай бұрын
please could you do an example using _Generic keyword??
@sonvallano897 Жыл бұрын
Great video
@PortfolioCourses Жыл бұрын
Thank you, I’m glad you enjoyed it! :-)
@yoruichi5802 Жыл бұрын
Saw a video of something similiar to manipulate floats, i think it was indirection or something… like this: float a; uint32_t temp = *(uint32_t*)&a; then manipulate the bits on the float and cast (float*) on it again
@PortfolioCourses Жыл бұрын
Cool! :-)
@justcurious1940 Жыл бұрын
But it has nothing to do with void !!! 🙃
@yoruichi5802 Жыл бұрын
Nice
@PortfolioCourses Жыл бұрын
I'm glad you liked it! :-)
@starc0w Жыл бұрын
Dear Professor Since you usually replied soon, I suspect you missed my message below. :-)
@PortfolioCourses Жыл бұрын
I haven’t had time yet to answer questions. :-)
@kunnudev7250 Жыл бұрын
awesome bro plz cont.....
@aleXelaMec Жыл бұрын
So why not using only void pointers!? Any disadvantages in size of such pointer?
@PortfolioCourses Жыл бұрын
Great question! :-) When we use a double pointer, and do pointer arithmetic, the compiler will adjust the pointer arithmetic to make it work for the size of a double (and this goes for any other type). With void pointers, this won't work. Typed pointers also allow the compiler to give us errors/warnings if we try to use them in ways that are unexpected.