Void Pointer in C.
#include<stdio.h>
#include<conio.h>
int main()
{
int a = 345;
float b = 6.9;
void *ptr;
ptr = &b;
printf("The value of b is %f\n", *((float *)ptr));
ptr = &a;
printf("The value of a is %d\n", *((int *)ptr));
return 0;
}
OUTPUT:
The value of b is 6.900000
The value of a is 345
Tysm
ReplyDeleteAwesome
ReplyDelete