%d format is for int. Not for long long int. Use the wrong format specifier, and the result is undefined behaviour.