Hi to all.
I have a small question regarding pointers concept is C. The code is below
Code:
#include<stdio.h>
#include<conio.h>
int main(void); //Prototype for main() function. Ofcourse not required
int main(void)
{
int i=2,*j;
j=&i;
clrscr();
printf("Value of i is %d\n",i);
printf("Address of i is %u", j);
getch();
return 0;
}
Output:
Value of i is 2
Address of is is 65524
Here my question is, we declared *j as int. The int data type range is -32768 to 0 to +32767. It is in 2 Bytes size. But how it able to print the address value which is beyond the range 32767. Actually we need to declare *j as
unsigned int *j;
Because unsigned int range is 0 to 65535. But instead of this, if we declare *j as
int *j;
it is able to print the value beyond specified range. How this is possible. Please let me know.
Thanks to all.