2
I’m having trouble reading a number initialized with long long
long long valid;
scanf("%lli", &valid);
Input:
025
The variable valid will have as content 21 and not 25
If I change %lli for %llu That already corrects the problem, but I don’t understand why, in fact, when using %llu should be to unsigned long long and not to long long.
How can I fix this? I must change to
%llu?'Cause that’s what happens when you write a number starting with
0?
When you start with
0, the remainder of the digits are treated as a number in base 8: https://msdn.microsoft.com/en-us/library/2k2xf226.aspxxx. - and25in base 8 is equal to21at base 10. Now why it works when it changes to unsigned, that I don’t remember (I need to get back to messing with C...)– hkotsubo
@hkotsubo When we change to unsigned probably the number is treated as decimal. Thank you
– Fábio Morais