/*****************************************************

	 xstring.c
	 Z-World, Inc, 2000

    Example of using xstring.

    This program demonstrates how to access
    the strings of an xstring declaration.

******************************************************/
//macro to access the (n-1)th element, like an array
#define XACCESS(m, n)	(m + (sizeof(long)*n))
xstring example{"string1", "string2", "string3"};
 
main(){
	long x;
	char data[20];

	//access the first member (index 0) of foo
	x = XACCESS(example,0); 
	xmem2root((void*) &x, x, sizeof(long)); 	// dereference x
	xmem2root((void*) data, x, sizeof(data)); // load string into data

	printf("first element of example is \"%s\"\n", data);

	//access the third member (index 2) of foo
	x = XACCESS(example,2);
	xmem2root((void*) &x, x, sizeof(long)); 	// dereference x
	xmem2root((void*) data, x, sizeof(data)); // load string into data

	printf("second element of example is \"%s\"\n", data);

}			

 