942,959 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 784
  • C RSS
Oct 14th, 2008
0

Array with pointer

Expand Post »
Hellow.......!
I need a help for: How will you declare an array of three function pointers where each function receives two integers and returns a float?
Reputation Points: 10
Solved Threads: 0
Light Poster
cutedipti is offline Offline
45 posts
since Sep 2008
Oct 14th, 2008
0

Re: Array with pointer

The simpler way (less error prone) is to use a typedef helper.
  1. typedef float ((*YourFunction)(int, int);
  2. YourFunction YourArray[3];
or, if you wish code that is terse but easier to get wrong (typos very easy), use this;
  1. float (*YourArrayAlternative[3])(int, int);
to declare an array named YourArrayAlternative.

Whichever way you choose to do it, I'll leave it to you to work out how to initialise array elements.
Reputation Points: 193
Solved Threads: 32
Posting Whiz in Training
grumpier is offline Offline
206 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: storage
Next Thread in C Forum Timeline: char *argv[] help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC