This is to cool!
Code:
#include <stdio.h>
typedef struct
{
int type;
int data;
} dint;
typedef struct
{
int type;
float data;
} dfloat;
typedef int object;
int main()
{
object test;
dint test_int;
dfloat test_float;
test_int.type = 0;
test_int.data = 1;
test_float.type = 1;
test_float.data = 2.5;
printf("assigning test_int to test\n\n");
test = (int)&test_int;
printf("the value of test = %i, the type of test = %i\n", *((int*)test+1), *((int*)test));
printf("adding 762 to test\n");
*((int*)test+1) += 762;
printf("the value of test = %i, the type of test = %i\n", *((int*)test+1), *((int*)test));
printf("\nassigning test_float to test\n\n");
test = (int)&test_float;
printf("the value of test = %f, the type of test = %i\n", *((float*)test+1), *((int*)test));
printf("adding 1.234 to test\n");
*((float*)test+1) += 1.234;
printf("the value of test = %f, the type of test = %i\n\n", *((float*)test+1), *((int*)test));
return 0;
}
100% dynamic typing! Thanks a lot guys.