| Forums.Sureshkumar.net : A Perfect Place to Share Knowledge Blogs Games Magazines |
|
|||||||
| ds. c , c++ Interview / Technical Questions Kindly solve an many as questions you can. It will sharpen your skills and those solutions will help others too. |
![]() |
|
|
LinkBack | Thread Tools | Rate Thread | Display Modes |
|
|
#1 (permalink) |
|
Moderator
Join Date: Nov 2006
Age: 25
Posts: 227
Thanks: 1 Thanked 12 Times in 9 Posts Thanks: 1
Thanked 12 Times in 9 Posts
Rep Power: 6
|
C language - Difference between Funtion to pointer and pointer to function
Difference between Funtion to pointer and pointer to function
|
|
|
|
|
|
#2 (permalink) |
|
Junior Member
Join Date: Aug 2007
Posts: 1
Thanks: 0 Thanked 0 Times in 0 Posts Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 2
|
Re: C language - Difference between Funtion to pointer and pointer to function
There is no such concept as FUNCTION TO POINTER.
We have POINTER TO FUNCTION. A pointer to a func is usually used to call that that function. Here there requires 3 steps. 1) Declare a pointer to the func which has the same signature as the func. eg) int calculate(int); // function int (*p)(int); // pointer to the above func 2) Assign the address of the function to the func pointer. The name of the func is itself the address of the function. p = calculate; By this we mean to say that P is a func pointer to the func "calculate". 3) To call the func using the function pointer....we use (*p)(5); // calls the calculate func. By (*p) ------> we mean the function "calculate". By passing 5 -----> we are passing an int value as an argument to this func "calculate". hence (*p)(5) means calculate(5). I hope this makes the concept clear... Last edited by Priyakk; 07-08-07 at 10:16 AM. Reason: Accidently submitted my post without completing my answer |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C questions | Spoorthi | DATA STRUCTURES, C, C++, VC ++ | 3 | 30-10-07 09:49 AM |
| C language - When would you use a pointer to a function? | GEEK | ds. c , c++ Interview / Technical Questions | 0 | 23-01-07 01:32 PM |
| C language -How do you use a pointer to a function? | GEEK | ds. c , c++ Interview / Technical Questions | 0 | 23-01-07 01:20 PM |
| Top 100 C Questions Asked in Actual Interviews | yathish | DATA STRUCTURES, C, C++, VC ++ | 1 | 30-12-06 09:50 PM |
| Help me for Interview question | ajutipu | EMBEDED SYSTEMS & VLSI | 4 | 31-08-06 08:04 PM |