Pointing to a function?

Started by
2 comments, last by gn0m3 21 years, 11 months ago
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
-Your human mentality screams for vengeance and thrives on the violence that you say you can hardly endure...
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.

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
-Your human mentality screams for vengeance and thrives on the violence that you say you can hardly endure...
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]

This topic is closed to new replies.

Advertisement