在Visual C++ 6.0中測試了一下,C/C++支持哪些常量表示形式。下面就是我實驗的例程。歡迎大家給出改進意見。
- #include <stdio.h>
- int main()
- {
- 1;
- 1l;1L;
- 1u;1U;
- 1ul;1uL;1Ul;1UL;1lu;1lU;1Lu;1LU;
- -1;
- -1l;-1L;
- -1u;-1U;
- -1ul;-1uL;-1Ul;-1UL;-1lu;-1lU;-1Lu;-1LU;
- 01;
- 01l;01L;
- 01u;01U;
- 01ul;01uL;01Ul;01UL;
- 01lu;01lU;01Lu;01LU;
- -01;
- -01l;-01L;
- -01u;-01U;
- -01ul;-01uL;-01Ul;-01UL;
- -01lu;-01lU;-01Lu;-01LU;
- 0x1;
- 0x1l;0x1L;
- 0x1u;0x1U;
- 0x1ul;0x1uL;0x1Ul;0x1UL;0x1lu;0x1lU;0x1Lu;0x1LU;
- 0X1;
- 0X1l;0X1L;
- 0X1u;0X1U;
- 0X1ul;0X1uL;0X1Ul;0X1UL;0X1lu;0X1lU;0X1Lu;0X1LU;
- -0x1;
- -0x1l;-0x1L;
- -0x1u;-0x1U;
- -0x1ul;-0x1uL;-0x1Ul;-0x1UL;-0x1lu;-0x1lU;-0x1Lu;-0x1LU;
- -0X1;
- -0X1l;-0X1L;
- -0X1u;-0X1U;
- -0X1ul;-0X1uL;-0X1Ul;-0X1UL;-0X1lu;-0X1lU;-0X1Lu;-0X1LU;
- 0xa;0xA;0XA;0Xa;
- 1.0;
- 1.0f;1.0F;1.f;1.F;1.0l;1.0L;1.l;1.L;
- 01.f;
- 09.f;
-
- '1';
- "1";
- true;
- false;
- return 0;
- }