Function Pointers and Regular Pointers
Distinguish between function pointers and regular pointers in this lesson.
We'll cover the following
Introduction
There are a lot of similarities between function pointers and pointers to variables. However, function pointers have a few particularities, which we’ll now discuss.
Function pointers are read-only
Function pointers point inside the .text
section, which should get mapped in a read-only memory area. As stated previously, it helps protect against code injection attacks. Moreover, it wouldn’t make sense to write to a function pointer. We would be effectively changing the program’s code while it’s running.
Let’s try to create a function pointer, write to it and see what happens.
Get hands-on with 1400+ tech skills courses.