In c programming why I am getting 0 zero for this? Why -5<(unsigned)5
is false?
main(){
printf("%d",-5<(unsigned)5);
getch();
}
Because it's doing it as an unsigned comparison, which means it's actually checking if UINT_MAX - 4 < 5
, which obviously is false.
IMO having no unsigned types is one of the few things Java really got right. It means you don't get headaches like this.
UINT_MAX
is over 4 billion, (assuming 32 bits as the default int size for your system,) that's to be expected.
Nov 25, 2015 at 19:23
printf
as if it were a pointer. Ongcc
this gives me an warning:passing argument 1 of 'printf' makes pointer from integer without a cast
. Bottomline: you want to have a comma between the format string and the next argument.