I read the documentation and it says that a long is %li but the print out comes back as -2147024891. What gives?
You didn't even provide which number you wanted to print, but I guess you've stumbled over the difference between signed and unsigned printing.
Use %lu
for unsigned long
numbers, and %ld
or %li
for signed long
numbers.
The MSDN has good documentation on printf specifiers. For 64-bit values (like long long
, for example), you should use the macros in <inttypes.h>
.
You are trying to print an HRESULT, the error code for "access denied". That is best formatted in hex, at least to be easily recognizable to a programmer and the Google query box.
printf("0x%08lx", hr);
Now you'll instantly recognize the facility code 7 (Windows API) and the error code 5 (access denied).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With