decimal to hex conversion in C
I need to conver decimal numbers to 4 digit lower-case hex numbers prefixed by 0x.
"%X" is good enough, but this is not exactly what I want.printf("hex num is: %X\n", num);
开发者_如何学PythonI guess you need either 0x%04x or %#06x.
%xmeans lower-case hex.0means padding with zeros if shorter than the specified number of digits.4or6specifies the desired width.#means0xprefix.
Is printf("hex num is : 0x%.4x\n", num); what you want?
Use printf("hex num is : 0x%x\n", num);.
加载中,请稍侯......
精彩评论