I know unsigned int* and int* are not compatible. But since i,j are int* (int pointers), then how are they printed using unsigned type. And why is it giving output 0!!
#include<stdio.h>
//#include<conio.h>
main()
{
int *i,*j,**k;
//i+2;
k=&i;
printf("\n*k=%u j=%u i=%u",*k,j,i);
//getch();
}
Output:
*k=0 j=0 i=0
It is one of the questions of 295 C questions, I'm just trying to understand what is happening in this code!! I didn't write this code!
As already stated in comments, you have undefined behavior as you use uninitialized variables so anything could be printed (or the program could crash).
So make sure to initialize your variables before using them.
Also you should print pointer values using %p
int main()
{
int *i,*j,**k;
// Initialize i, j and k
int x = 42;
i = &x;
j = &x;
k=&i;
// Use i, j and k
printf("\n*k=%p j=%p i=%p",(void*)*k, (void*)j, (void*)i);
return 0;
}
Example output:
*k=0xbfd9eb8c j=0xbfd9eb8c i=0xbfd9eb8c