#include<stdio.h>
#define int int*
main(){
int *p,q;
p=(int *)5;
q=10;
printf("%d",q+p);
}
my question is that in line p=(int *)5
, and q=10
how it's working internally exactly because p
and q
are both pointer types, how is it possible that we can assign an integer value to pointer variable q
?. One more thing how this type casting p=(int*)5
working here ?
By using this formula we can answer
new address = old address+number * sizeof data type to which pointer is pointing
See Question&Answers more detail:os