Computer Programming
C Programming
Algebra

What is the main use of the function pointer?

808182

Top Answer
User Avatar
Wiki User
2010-06-09 04:47:41
2010-06-09 04:47:41

Function Pointers are basically used when we want to select a function which is to be used dynamically at run time.

AnswerFunction pointers are the only way for "Interept programming". In UNIX all the Interepts are called using function pointers. This is mainly used in system programming. Answerits nothing but a pointer to function. which is similar to ptr to a variable, if we are saying ptr to a variable then it will hold address of the variable like that fn. ptr will have the address of the function..

one of the major application of the function pointer is call back function.. i.e callback.

AnswerPointers to functions/methods/subroutines aka 'Delegates' are frequently used in .NET programming especially in EventHandling, MemberInvoking

<><><>

A function pointer is used to pass a function as an argument to another function, or to store a function as a data item, for example a list of functions can be implemented as an array of pointers to functions. Function pointers are used to store interrupt handlers in tables.

12
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
๐Ÿ˜‚
0

Related Questions

User Avatar

A pointer to a function is the memory address that stores the address of a function, while the pointer itself is a function pointer.A pointer to a function might be defined as "int (*pf)(int, int);", while to actually point to the function, you would use a function pointer, such as "pf = &func;".

User Avatar

Usable. A prominent example is param argv of function main.

User Avatar

Yes. For example, argv parameter of function mainis a pointer to an array of pointers to characters.

User Avatar

function pointer is a variable that hold the address of any function which declared in the program but function pointer is the array of the function that accept the run time size of the function.

User Avatar

A static function is a member function that is not associated with any instance of the class; it has no this pointer.

User Avatar

*function();this declares a pointer function!

User Avatar

Simply by sending the base address from main() and catching that in a pointer in the pointer. void main() { int a[20]; sort(a); } void fun(int *p) { }

User Avatar

Nothing. You might have meant pointer-to-function.

User Avatar

If you mean example, then it is argv, which is the second parameter of function main.

User Avatar

A double pointer has two basic meanings. One is ofa pointer to a pointer, where changing the value ofdouble pointer will result in the original pointer being changed. Another is that of a two-dimentional array, such as a matrix, or a list of char* (e.g. in main when you use argv).

User Avatar

You point at the array the same way you would with an array of any pointer type, by using an additional level of indirection than is employed by the pointers in the array itself. In this case, the array contains pointer-to-function data types (with one level of indirection), thus you must use a pointer-to-pointer-to-function data type (with two levels of indirection) in order to point at the array itself. Had the array contained pointer-to-pointer-to-function data types (where each pointer points to a separate array of pointer-to-function data types), then you'd use three levels of indirection, and so on. You increase the level of indirection by placing an additional asterisk before the pointer's name when you declare the pointer. That is, one asterisk per level.

User Avatar

Pointer in C is Memory Reference. It stores memory address of any variable, constant, function or something you later use in your programming. Pointer basically used to ease the referencing of variables and others or in polymorphism and inheritance.

User Avatar

Yes. A function can return a pointer... const char* GetHelloString() { return "Hello!"; } ... returns a pointer to the string "Hello!".

User Avatar

A pointer to pointer variable can hold the address of another pointer variable. The Syntax is as follow: type** variable; Example:: //function prototype void func(int** ppInt); int main() { int nvar=2; int* pvar=&nvar; func(&pvar); .... return 0; }One more important use of pointer-to-pointer is for creating multi-dimensional array dynamically, see See the related links.

User Avatar

To aid in the use of the computer by allowing you to move a pointer around the screen and do things much faster than just using a keyboard

User Avatar

It is to show you that the pointer is on the zero mark.

User Avatar

typedef int (*myfunptr)(int argc, char **argv); myfunptr m= main;

User Avatar

Because if you donot use main function in c program, the compiler willnot execute the program.C compiler starts execution from main function itself.

User Avatar

Parameters are the formal arguments of a function, as defined by the function. When you pass arguments to a function, those arguments are assigned to the function's parameters, either by value or by reference, depending on how the parameters are declared in the function. The following example explains both: void foo( int param ) { // param is a by value parameter, which is a copy of the argument passed to it. } void bar( int&amp; param ) { // param is a reference parameter, which references the argument passed to it. } int main() { int arg = 100; foo( arg ); bar( arg ); return( 0 ); } Note that passing a pointer is the same as passing an int by value: the pointer's value is passed to the function, not the pointer itself. To pass a pointer by reference, you must pass a pointer to pointer and the function's parameter must accept a pointer to pointer.

User Avatar

Pointer variables and function pointers are the two primary types, as well as a void pointer (unknown type). Pointer variables can point to any valid type, including primitive types and user-defined types, as well as other pointer variables. Function pointers can point to any function with the same signature as the function pointer itself. Void pointers can point anywhere.

User Avatar

Double pointers are better known as pointer-to-pointer types. You use pointers to store the memory address of an object but when the object is itself a pointer, you need to use a pointer-to-pointer in instead. Pointer-to-pointer types are typically used when passing pointers into functions. Pointers allow you to pass objects to functions by reference but the pointer itself is passed by value. If you want to pass the pointer by reference, you need to pass a pointer-to-pointer.

User Avatar

The function ftell returns the position of the file pointer for a file.

User Avatar

A pointer which keeps address of a function is known as function pointer. example: { void *(*ptr)(); ptr= &amp;display; (*ptr)(); return(0); } void display() { .................. )

User Avatar

To point with. 1. To manipulate parts of an array. 2. To return more than value from a function.


Copyright ยฉ 2020 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.