• Advertisement

Archived

This topic is now archived and is closed to further replies.

Pointing to a function?

This topic is 5771 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to have a pointer to a function in C or C++? If so please tell me how. Your human mentality screams for vengeance and thrives on the violence that you say you can hardly endure

Share this post


Link to post
Share on other sites
Advertisement
Yes. An example in C:

#include <stdio.h>

void Function(void) {
printf("Fish\n");
}

int main(void) {
void (*FuncPtr)(void) = Function;

FuncPtr();

return 0;
}

What more information and/or examples? Then use Google.

Share this post


Link to post
Share on other sites
thx, i had the general idea right just couldn''t get the parenthesis in the right place 8o)

Your human mentality screams for vengeance and thrives on the violence that you say you can hardly endure

Share this post


Link to post
Share on other sites
go here
(actually the first hit you get when you search for "function pointer" on google ) Very nice site, near everything that you need to know about C/C++ fptr's all in one place

[EDIT] - damn tags!
Wannabe
warning C4786: identifier was truncated to '255' characters in the debug information
Test.exe - 0 error(s), 76 warning(s)

[edited by - Rickmeister on May 2, 2002 2:38:09 AM]

Share this post


Link to post
Share on other sites

  • Advertisement