Hi All
If I assign any -ve value to an unsigned int variable
I never find any warning while compiling...
& it prints the correct value also....
I donno the reason behind this....
expecting your comments...
thanks & regards
Sanjeev
Hi All
If I assign any -ve value to an unsigned int variable
I never find any warning while compiling...
& it prints the correct value also....
I donno the reason behind this....
expecting your comments...
thanks & regards
Sanjeev
C doesn't warn on overflows.
And it's probably showing up right because you're printing it with printf() using %d instead of %u which means printf() is just reading it as a signed int instead of unsigned. Try using the correct format specifier (%u) for unsigned int and you should see something different.
If you understand what you're doing, you're not learning anything.