Function pointers in C let you declare variables that can point at pieces of code instead of pointing at data. That lets us delay binding what function we want to use all the way to run-time which gives us great flexibility. Combining this idea with table driven logic can help us create really clean code for complicated situations. I have crafted a sequence of examples to show you how function pointers work and how to use them in table driven situations. You can find the code for these examples at: https://drive.google.com/drive/folder...
In this video I'll walk you through:
what a function pointer is
how to declare and use function pointers
a tax calculating example using function pointers in a stair step table logic
a mini-assembly language interpreter that uses a table to select how to process a given command
TIMESTAMPS
0:00 What is a function pointer?
0:16 Tax Example Set up
1:00 Declaring a Function Pointer
1:40 Assigning and Using a Function Pointer
2:48 Combining Function Pointers and Table Driven Logic
4:57 Assembly Interpreter Example
5:48 Assembly Interpreter Table
6:24 Assembly Interpreter Overview
8:07 Assembly Interpreter Using the Table
9:00 Conclusion
ABOUT MY CHANNEL
My channel is about good software engineering practices. We cover introductions to programming in C and Java. But I also have lots of software and computer engineering topics like PIC programming, advanced programming techniques, and things that distinguish good code from code that works.
Check out our channel here:
/ @wizardcraftcode
Don’t forget to like and subscribe!
CHECK OUT MY OTHER VIDEOS:
Table Driven Logic: • Table Driven Logic - Using data to simplif...
C Programming Playlist: • Coding in C
Intro to Java Playlist: • Introduction to Java Programming based on ...
Software Engineering Topics Playlist: • General Software Engineering Topics