Functions: call a function vs pointer functions. Differences? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Functions: call a function vs pointer functions. Differences?

Hello Everybody! I'm Learning C Programming language, and I'm not understand the difference between call a functions by value and call a function by pointer functions. PD: Excuse me if my English is not good.

18th Jun 2020, 11:17 PM
CodeKid
4 Answers
0
It's not quite clear what you are trying to ask. Do you mean passing parameters to a function "by value vs by reference" or "call a function by a pointer"?
19th Jun 2020, 1:00 AM
Vasile Eftodii
Vasile Eftodii - avatar
0
Hi! Thank you for ask my question. What is the difference between call a function by normal way and call a function by a pointer?
19th Jun 2020, 1:08 AM
CodeKid
0
Internally there is no difference. A function is nothing more than a set of instructions. The source code we are writing and can read is then compiled (converted) in binary (machine) code. In this code there are no variable or function names, identifiers, etc. When you call a function the program jumps on a specific memory address and continues its execution from this point. But different programming languages have different approach. For example C/C++ load the function call in RAM (local variables plus the last exit point). These means that you need to be very careful when using recursion and avoid infinite function self calls. This will fill the maximum RAM memory allocated for your application and your program will unexpectedly crash. Calling a function by a pointer allows you to call any function you need, but not sure which one at that moment. This is mostly used in call back mechanism and components events.
19th Jun 2020, 8:03 AM
Vasile Eftodii
Vasile Eftodii - avatar
0
When you click a button (this generates an event) you assign to this event a function to be called. This function will execute the set of instructions you have defined inside of it's body. Here are implied pointers to functions. You have a library of components and they are generalized. A component (object or instance of a class) may be used as many times you need and they are generalised.
19th Jun 2020, 8:08 AM
Vasile Eftodii
Vasile Eftodii - avatar