How do you initialize function pointers? Give an example?
Answers were Sorted based on User's Feedback
Initialisation can be done in the following way.
func(int a,int b);
*pfunc(int a, int b);
main()
{
/*here the starting address of the function can be assigned
to a function pointer of the same type*/
pfunc = func;
....
....
....
}
func(int a, int b)
{
....
....
....
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / preeti singh
for e.g. if we have to declare a pointer to a function , the
signature of which is :
int add(int a,int b)
then a pointer to the above function can be declared as:
int (*myptr)(int ,int);
here myptr is a pointer which can point to any function that
takes 2 int args and returns an int value.
| Is This Answer Correct ? | 1 Yes | 1 No |
How to declare pointer variables?
write a C code To reverse a linked list
Is javascript based on c?
What is a static function in c?
What happens if a header file is included twice?
How do I create a directory? How do I remove a directory (and its contents)?
EXPLAIN #INCLUDE<STDIO.H> EXPLAIN #INCLUDE<CONIO.H>
How can I find out the size of a file, prior to reading it in?
Heyyy All, Just a challenge . A C program with if Else if(){ /// insert sumthing print ("in if") // insert sumting } else { ///// insert sumthing print ("in else"); //// insert sumthing } can anyone modify it so that program prints. if and else both
Describe the header file and its usage in c programming?
If we give two names then this displays the connection between the two people. It is nothing but flames game
Given an array A[n+m] of n+m numbers, where A[1] ... A[n] is sorted and A[n+1] ... A[n+m] is sorted. Design a linear time algorithm to obtain A[1...n+m] sorted using only O(1) extra space. Time Complexity of your algorithm should be O(n) and Space Complexity O(1).