C Unsigned int providing a negative value?
问题 I have an unsigned integer but when i print it out using %d there is sometimes a negative value there? 回答1: Printing %d will read the integer as a signed decimal number, regardless of its defined type. To print unsigned numbers, use %u . This happens because of C's way to handle variable arguments. The compiler just pulls values from the stack (typed as void* and pointing to the call stack) and printf has to figure out what the data contains from the format string you give it to. This is why