Skip to main content

Command Palette

Search for a command to run...

Function pointer confusion cleared

Published
1 min readView as Markdown
Function pointer confusion cleared
X

"I am currently a Software Engineering student at ALX. I'm passionate about technology and enjoy conducting research to find answers on my own. I have a natural inclination to ask 'WHY' more often than 'HOW'.

"While working on projects at ALX, I have acquired a wealth of interesting and diverse knowledge about software engineering and computer science in general. Therefore, I needed a place to store and save all this information, allowing me to refer back to it whenever I forget."

The two examples below will work interchangeably, but for easier remembrance and understanding, stick with one convention

int (*ptr)(int, int) = ∑ s = (*ptr)(1, 2);

OR

int (*ptr)(int, int) = sum; s = ptr(1, 2);

both still work, so choose one convention and stick with it

NB: function pointers contain the address of the code while other pointers contain the address of the value

More from this blog

PERSONAL BLOG

110 posts

Use the search button to search for a specific topic or keyword *all posts are updated on the go*