The difference between %x and %x in C language

下次还敢
Release: 2024-04-29 18:27:14
Original
774 people have browsed it

In C language, %x prints integers in lowercase hexadecimal form, and %X prints integers in uppercase hexadecimal form.

The difference between %x and %x in C language

The difference between %x and %X

In C language, %x and %X are both formats ization placeholder for printing integers in hexadecimal form. The main difference between them is case.

%x

  • Print the integer in lowercase hexadecimal form.
  • The resulting value always contains lowercase letters.
  • For positive integers, the 0x prefix is ​​not automatically appended.
  • For negative integers, a 0x prefix is ​​automatically appended, followed by the negative's complement.

%X

  • Print the integer in uppercase hexadecimal form.
  • The resulting value always contains uppercase letters.
  • For positive integers, the 0X prefix is ​​automatically appended.
  • For negative integers, a 0X prefix is ​​automatically appended, followed by the negative's complement.

Sample code:

<code class="c">int i = 100;
printf("小写十六进制:%x\n", i);  // 输出:64
printf("大写十六进制:%X\n", i);  // 输出:64</code>
Copy after login

Summary:

  • %x in lower case hexadecimal The form prints an integer.
  • %X Prints an integer in uppercase hexadecimal form.

The above is the detailed content of The difference between %x and %x in C language. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template