Skip to content

Instantly share code, notes, and snippets.

@leffuy
Created February 11, 2012 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leffuy/1797772 to your computer and use it in GitHub Desktop.
Save leffuy/1797772 to your computer and use it in GitHub Desktop.
Function Pointer Tests
#include <stdio.h>
#include <stdarg.h>
static int playerX = 0;
static int playerY = 0;
struct functionParams{
int dX;
int dY;
};
struct functionHolder{
int (*FunctionPointer)(void* null);
};
int myFunctions(void* null){
struct functionParams* funcfunc = (struct functionParams*)null;
playerX += (*funcfunc).dX;
playerY += (*funcfunc).dY;
}
int main(int argc, char** argv){
struct functionHolder funkyMan;
struct functionParams paramMan = {5, 5};
funkyMan.FunctionPointer = &myFunctions;
funkyMan.FunctionPointer((void*)(&paramMan));
printf("X: %d Y: %d",playerX,playerY);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment