My initial tests. My goal is to access the type member of the dynamic_int struct instance "test1". So far it does not work. I'm using Visual C++ 2008 Express Edition on a P4.
Code:
#include <stdio.h>
/*define a dynamic int. a dynamic object will hold the mem address of the struct holding
the current value of that dyanmic object*/
typedef struct
{
int type;
int data;
} dynamic_int;
int main()
{
/*create a dynamic integer for tests*/
dynamic_int test1;
/* initalize the data members */
test1.type = 0;
test1.data = 1;
/*print the memory addresses for the struct, the type member, and the data member*/
printf("test1 %#x, type %#x, data %#x\n", &test1, &(test1.type), &(test1.data));
/*try the print the value of the type member, then print the address of that member*/
printf("test1.type = %i, address = %#x\n", (int *)((&test1)), (&test1));
return 0;
}