Callback Functions in C Explained
Vložit
- čas přidán 4. 07. 2024
- This video explains callback functions and shows how to implement them in C.
At the start, basics of callback functions are explained. Next, an example is shown that demonstrates how to easily implement callback functions in C. Lastly, an example is shown on how to use the qsort() function that is inside the C standard library.
Code:
github.com/CodeflashVideos/ca...
Chapters:
00:00 Introduction
00:18 Basics of Callback Functions
02:05 First Example: Implementation, Passing and Calling Callback Functions
05:58 First Example: A Simplification of the Function Pointer Syntax by Using a typedef
07:03 Second Example: An Explanation of the qsort() Function Which Uses Callback Functions
08:58 Second Example: An Implementation of a Comparison Callback Function and It's Usage for the qsort() Function
13:15 Outro
LIKE | COMMENT | SHARE | SUBSCRIBE - Věda a technologie
My question was answered within the first 40 seconds of the video, "What is a callback function?" Answer: "A callback function is a function that is passed to another function as an argument." Good Stuff!
Clear and straight to the point. Thanks.
Thank You for going more in depth in your example using qsort. Look forward to your "C" videos!
You explained it well .it is very good and easy to understand.
I really liked the content. At these days it is very hard to find a deeply and simply videos. Thanks
найс инглиш, мой славянский друг )
very informative.
that type of deep knowledge content we need.
please make more of these types of videos.
Wow, I understand everything you explained in the video so easily! Thank you very much!
Easy to understand. We can directly call the callback function just like a normal routine. Why we made them function pointer?
int main(){
add(5,5):
}
This video is great, You cleared my concept of callback and function pointer, Thanks a lot
Best Callback Explanation Ever! Thanks my friend, GBY!
That’s was such a good explanation, thanks!!
Short and precise description 👍👍👍
Very good explanation and sample of function pointer
Thank you very much. Very precise and to the point.
I have a question. Is it possible to implement asynchronous callback functions in C?
Nice explanation.
Plz add more vdos on this topic like sending struct pointer and many more.🙏🙏
Great explanation !!
Awesome video. Thank you for the explanation! :)
Hey, thanks for your input.
Please keep in mind that the video is about implementing callback functions in C while you are talking about C++. C doesn't support lambda expressions.
Thank for this video, really helped me.
Very good.
great video
good bro
Thaks a lot!
Can you implement asynchronous call back function?
Could you please share video with information regarding how callback function is different from goto ?
I am clearing my own mind. Just correct me if I am wrong :
"Using compar as the way it is defined (i.e. int compar (const void *p1, const void* p2); allows a custom comparison function even for objects derived from a class via type casting in compar function same as the way you have done by casting those void* pointers to int* pointer. "
If I understood above correctly, I think I have understood the utility of call back functions correctly. Please verify my understanding and oblige.
Thanx 😅
everyone explains what you explained...but give real time example of synchronous and asynchronous callback functions
So callback functions are like interrupts?
They are more like interrupt service routines.
@@codeflash6896 Why don't use function call from inside the function? What added value we get from putting function as argument?
Because different callback functions can be called from a single "main" function.
By providing the callback function as an argument to a "main" function, the code is more generic since only this "main" function is needed to call different callback functions within it.
The alternative would be to have multiple different "main" functions that each call their hardcoded callback function. This creates code duplication.