// Written by Joe Gillotti #include // Number of items in our void pointer #define NUM_ITEMS 3 int main() { // Our actual values char c = 't'; int d = 99; float b = 3.14; // This array defines the types so we know what to expect char types[] = {'d', 'c', 'f'}; // The array of void pointers itself void *ptrs[] = {&d, &c, &b}; // Go through the void pointer array.. int i; for (i = 0; i < NUM_ITEMS; ++i) { // Use our types[] array to discern what type of pointer we have switch (types[i]) { case 'd': printf("Array index %d is a digit who's value is %d\n", i, * // Dereference the now int pointer (int*) // (read this first, then above^) Turn this typeless pointer into an int pointer ptrs[i]); break; case 'c': printf("Array index %d is a char who's value is %c\n", i, *(char*) ptrs[i]); break; case 'f': printf("Array index %d is a float who's value is %.2f\n", i, *(float*) ptrs[i]); break; } } return 0; }