%x and %o in C language
In C language, "%x" and "%o" are format specifiers used in format strings. Used to specify how to print integers:
Usage:
To print an integer in hexadecimal or octal format, you need to use formatting functions such as printf() or sprintf() . The format specifier is placed before the variable to be printed. For example:
<code class="c">int number = 123; printf("十六进制:%x\n", number); printf("八进制:%o\n", number);</code>
Output:
Running the above code will output:
<code>十六进制:7b 八进制:173</code>
Note:
The above is the detailed content of What do %x and %o mean in C language?. For more information, please follow other related articles on the PHP Chinese website!