I guess we saw that happening due to incompatible type casting. When we use char *p = &i : due to signed / unsigned type casting (underflow) unsigned 255 becomes signed -1 hence the values of j and k. Try to run below: int main(){ unsigned int i = 255; int *p = &i; int j = *p; unsigned int k = *p; printf ("i : %d \n", i); printf ("j : %d \n", j); printf ("k : %d \n", k); return 0; }
Let me know your thoughts.
64.3k questions
77.9k answers
243k comments
79.6k users