You would have passed sa "long long" or "unsigned long long" either explicitly or implicitly to the printf, which is why you get the warning -- but more on that later;
Generating a 10 digit random number, you will need to switch to 64 bit -- so long long;
unsigned long long randomvalue;
randomvalue = random();
randomvalue <<= 16; // just picked 16 at random
randomvalue ^= random(); // you could also use + but not "or";
randomvalue %= 10000000000ULL;
The warning you get is because you pass a value of type long long
as the third argument to the printf
function, but you still use "%u"
as the format, which makes printf
expect a value of type unsigned int
.
To silence the warning, change the format to "%lld"
.
It won't help you create a ten-digit number higher than 2147483647
though, as rand
returns an int
which so far is at most 32 bits, even on 64-bit platforms. Where the value 2147483647
comes from? The highest positive value if a signed 32-bit integer.