I'm starting to program in C and I'm having a problem to understand some results I'm getting. I'll paste the code here:
#include <stdio.h>
unsigned int main(void)
{
unsigned int x = 0;
printf("%u\n",x-1);
return 0;
}
The terminal is returning 4.294.967.295, and I'm not getting why. I know that this value is the max value of a unsigned int
, but actually I was expecting some warning from the compiler that I would have to use a int
type not an unsigned int
because the result is negative. Anyway, can someone help me?