![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
How to pass a function name as an argument to another functionI found and adapted the following suggestion from elsewhere, but it crashes my compiler. I'm using Interactive C (www.handyboard.com), so that may be the only problem, but does anyone know if I'm using this wrong, or if there are any other tricks to do this?
CPP / C++ / C Code:
p.s. My project partner insists I use this smilie: Sorry. |
|||
|
#2
|
|||
|
|||
|
Quote:
Since you didn't show all of your code, I can't really suggest corrections. However... Here is an example that is standard C (also standard C++) If your compiler doesn't like this (or it doesn't work), ask for your money back. You should be able to use this to see how to change your program. If you don't understand how I declared and used the pointer-to-function, ask for additional explanations. CPP / C++ / C Code:
Regards, Dave |
|
#3
|
|||
|
|||
|
Quote:
I just now looked at your link. My previous response in standard C may, indeed, not work for this micro version subset of C (The wisecrack about getting your money back was uncalled for.) I have no way of testing your code (or mine) since I don't have a handyboard to use for investigation. Anyhow, the notation that I used in my example is standard C. You can try it and see what happens. Good Luck! Regards, Dave p.s. My attitude towards C running on 8-bit 1980s-vintage microcontrollers is kind of like my opinion of dancing bears: I'm impressed not by how well they dance, but that they dance at all. (If I knew who first used the "dancing bear" metaphor, I would give them credit.) D. Last edited by davekw7x : 04-Feb-2005 at 10:41.
|
|
#4
|
|||
|
|||
Re: How to pass a function name as an argument to another functionThanks to Dave for taking the time to post that!
I was stuck and frustrated getting a complex bit of code to run but your clearly commented example did the trick. |
Recent GIDBlog
Running Linux Programs at Boot Time by gidnetwork
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Include] Doubly-linked List | dsmith | C Programming Language | 6 | 14-Apr-2006 13:12 |
| [GIM] gim.h | dsmith | C Programming Language | 0 | 18-Jan-2005 08:48 |
| Nested for loop with function | Tori | C++ Forum | 11 | 08-Nov-2004 13:02 |
| Revising Script style ?????? | pepee | MySQL / PHP Forum | 4 | 14-Apr-2004 04:59 |
Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The