[Solved] Assigning/Casting integers to pointers


#define int int* will replace int *p, q as int* *p, q. So Here p is double pointer to int and q is of type int.

For example consider the below program of your same logic in char

#include<stdio.h>  
#define char char*  
main()
{     
    char *p,q;     
    printf("%d, %d\n", sizeof(p), sizeof(q));
} 

Output is

4, 1

p=(int *)5; – This statement also will be replaced like p=(int* *)5; by preporcessor. So its not throwing any warning.

so now printf("%d",q+p); will gives you 45 in case of 32 bit machine or 85 incase of 64 bit machine.

solved Assigning/Casting integers to pointers