I don't understand the difference between
printf("%ld \n", 9999999991474836499);
printf("%lld \n", 9999999991474836499);
printf("%ld \n", 999999999147483649);
printf("%lld \n", 999999999147483649);
long long int
On some computers,
long long have the same representation, so
l do the same thing. This is true for most 64-bit platforms, except Windows. (This is an explanation of why it worked that way, not a promise that it must work that way.)
On other platforms—64-bit Windows, 32-bit anything, you will not be so lucky.
The program is incorrect either way, it just happened to work by chance, and there is no guarantee that it will continue to work, even on the same platform.