Forums.Sureshkumar.net : A Perfect Place to Share Knowledge         Blogs     Games    Magazines    

"Sharing knowledge does not lessen your store, often it gets you more. Sharing plays a key role in relationships and bonding, happens in small steps and is assisted through community membership."

Go Back   SURESHKUMAR.NET FORUMS > TECHNICAL DISCUSSIONS > DATA STRUCTURES, C, C++, VC ++ > ds. c , c++ Interview / Technical Questions
Register FAQ Members List Calendar Games Blogs Search Today's Posts Mark Forums Read

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.

   

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Old 23-01-07, 01:36 PM   #1 (permalink)
Moderator
 
GEEK's Avatar
 
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 GEEK is on a distinguished road GEEK is on a distinguished road
C language - Difference between Funtion to pointer and pointer to function

Difference between Funtion to pointer and pointer to function
GEEK is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 07-08-07, 10:08 AM   #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 Priyakk is on a distinguished road
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
Priyakk is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT +6.5. The time now is 12:34 PM.





Search Engine Optimization by vBSEO 3.1.0