I made the following program
#include <stdio.h>
int main()
{
// Testing Number
unsigned int num;
printf("Enter The Number : ");
scanf("%u" , &num); // If I Enter 4294967298
printf("Your Number is : %u" , num); // Output Comes Out To Be 2
}
Now in the above program if enter 4294967298
Output Comes Out To Be 2
, and here on stackoverflow, answers are saying that if you enter number more than the required range then the scanf
will store the UINT_MAX
and will print that, inspired by that answer, and discussion going on it being wrong and such. I tried on my own and it is not behaving like this instead after range it is printing after doing modulo arithmetic.
If one could point to what the standard says about it, it would be very helpful.
I have read the other answer, and both answers on that question are conflicting and no one is giving the correct one, selected answer differ on the topic.
Is it implementation dependent?
And many People seem to differ in this question, if you could support your argument with reference to standard, it would be highly appreciated.
If someone find anything wrong with this question, please do tell me in the comments.