#include <stdio.h>
void print_value(void *ptr, char type)
{
switch (type)
{
case 'i':
printf("%d\n", *(int *)ptr);
break;
case 'f':
printf("%f\n", *(float *)ptr);
break;
case 'c':
printf("%c\n", *(char *)ptr);
break;
default:
printf("Invalid type\n");
break;
}
}
int main()
{
int i = 10;
float f = 3.14;
char c = 'a';
print_value(&i, 'i');
print_value(&f, 'f');
print_value(&c, 'c');
return 0;
}