Function Pointers | C Programming Tutorial

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

The idea of function pointers isn't terribly difficult...it's the syntax that's confusing. You explain it very well, though. This channel's a goldmine!

bettyswunghole
Автор

this is my second time to watch this lesson, and the picture is more cleared. all what is explained has a sens and targeted the main core of pointer and its their use. You put all such effort to make it accessible and detailed for US, a work that has a GREAT MERIT. thank you

naboulsikhalid
Автор

The best function pointer video I have come across

sakib
Автор

Loved this. I have been using structs as if they were classes, and function pointers as if they're class methods :'D

charlene
Автор

This one video condenses so much. Examples are excellent templates. Brilliant content, thank you so much

lisandroiaffar
Автор

Callback functions in C make me appreciate virtual functions in C++ so much more :D

enzocalzone
Автор

Everything about function pointers covered in one video. Great. Thanks.

RakeshSolanki
Автор

The function returning a function pointer was cool, I haven't seen that syntax before, but it makes total sense.

MorningNapalm
Автор

This is the most beautifully and exceptionally well explained one of a kind video on a Function Pointers in C. Wow 🤩 amazing bravo 🙌 Thanks from India 🇮🇳.

Shivottmam
Автор

Great video! A few days ago I was researching for ways to introduce some sort of polymorphism in my generic linked list library when I stumbled upon function pointers. It completely blew my mind. I had not even the slightest idea you could do this with functions! It's crazy!
Actually, I've been looking for this solution for quite a long time, but as I didn't know much of C or programming in general I didn't even know how to look for it. It wasn't until I started learning OOP fundamentals recently that I started getting hints of it. So, it's a particularly satisfying discoverment!

Today I could finally start trying this out in my programs, but I'm having trouble understanding some things. In college we've been taught that a good programming practice is to declare functions, then define / implement them. In a similar manner, we've also learned from Abstract Data Types (I dunno the acronym in english, in my country is TDA) to declare all the interface's functions in the .h file, then define them all in a .c file.

Without going much further, I was making a function "printData" that recieves a void pointer to some data and a pointer to a function to print that data according to its type (print_int if it's an integer, print_string and so on). I did an empty project and put everything only in the main.c file to be minimalistic. I first tried declaring all the functions above the main() function, then defining them below it, but it didn't work. Then I noticed that it does work when you just do it above the main function (declaration and implementation). My questions are:

- Why is this?

And, related to what I previously mentioned:

- How should I do it when working with multi-file projects?

It's also really plausible that I'm making a mistake so I'll double check, but ultimately my questions still stand.

FranksCreativeCorner
Автор

I haven’t programmed in C in a two years and watched this out of curiosity but damn this video made it all click again

poopoo-dkhu
Автор

Another great & simple explanation, thanks for creating it!

aurinator
Автор

This is a great vid; have always been interested in making C do more dynamic things and this is a great illustration of how function pointers can accomplish that. Great explanation of these concepts

vsufnyz
Автор

Nice Explaination Sir!!
Keep the good work going.

mr.dhillonkpt
Автор

I found this really interesting but I’m left with a basic question - why would you do this? Even undergrad level programming courses do something similar and launch into explaining a complicated topic without first setting up why you might need to do this thing. It might be how my older brain is wired but I really respond better to a teaching process like this:
* I want to do a thing (give a real world example of something that people will actually relate to)
* Explain (or better, show) why what you’ve learned so far won’t be able to do this thing
* Demonstrate how the new technique you’re about to teach solves this problem
* Get into the details and teach the new topic

I really do love the pacing and format of your videos (awesome work!) but I’m still struggling to connect it to a reason why this might be needed.

Danbotics
Автор

Without looking this up (it is really late), I think you don't need to say "(*function_pointer)(4);". I think you can just say "function_pointer(4);", since it is a variable which is a pointer, just like an array.

MorningNapalm
Автор

Amazing video. Crystal clear explanation

bhagwatshinde
Автор

One of the most interesting videos in the list up to now in my opinion. Learned a lot! I just do not totally agree with the idea that instructions are not data. That depends largely on the definition of data. The most precise I know is that data is defined as the lack of uniformity, in other words any perceivable difference (not meaning involved, data is not information) is data and instructions are perceivable differences therefore data. But you use instruction in a a different way then other bits of data. it still data though. That is the built of writing programs they are data that tell how to operate on data.

vicsteiner
Автор

thank you so much. You have become my go to channel to learn c.❤❤❤❤❤❤

preciouslife
Автор

Thank you for this precious content. Im brazilian and I've following your videos

silvioesilvanice