Created
February 11, 2012 08:23
-
-
Save leffuy/1797772 to your computer and use it in GitHub Desktop.
Function Pointer Tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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*)(¶mMan)); | |
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