C – Pointer Type Casting

Pointer type-casting:

  • Converting one type of pointer variable into another type to access the data.
  • (type*) syntax is used to perform type casting.
#include<stdio.h>
void main()
{
            int i = 100;
            int* ip;
            char* cp;
            ip = &i;
            cp = (char*)ip;
            printf(“i value : %d\n”, *ip);
            printf(“i value : %d\n”, *cp);
}
Scroll to Top