user-0 提问: c新人求助/

回复:
user: user-1
content: C++ Integer Constants Integer constants are constant data elements that have no fractional parts or exponents. They always begin with a digit. You can specify integer constants in decimal, octal, or hexadecimal form. They can specify signed or unsigned types and long or short types.  Syntax  integer-constant :  decimal-constant integer-suffixopt octal-constant integer-suffixopt hexadecimal-constant integer-suffixopt 'c-char-sequence'  decimal-constant :  nonzero-digit decimal-constant digit  octal-constant :  0 octal-constant octal-digit  hexadecimal-constant :  0x hexadecimal-digit 0X hexadecimal-digit hexadecimal-constant hexadecimal-digit  nonzero-digit : one of  1 2 3 4 5 6 7 8 9  octal-digit : one of  0 1 2 3 4 5 6 7  hexadecimal-digit : one of  0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F  integer-suffix :  unsigned-suffix long-suffixopt long-suffix unsigned-suffixopt  unsigned-suffix : one of  u U  long-suffix : one of  l L  64-bit integer-suffix :  i64  To specify integer constants using octal or hexadecimal notation, use a prefix that denotes the base. To specify an integer constant of a given integral type, use a suffix that denotes the type.  To specify a decimal constant, begin the specification with a nonzero digit. For example:  int i = 157;   // Decimal constant int j = 0198;  // Not a decimal number; erroneous octal constant int k = 0365;  // Leading zero specifies octal constant, not decimal  To specify an octal constant, begin the specification with 0, followed by a sequence of digits in the range 0 through 7. The digits 8 and 9 are errors in specifying an octal constant. For example:  int i = 0377;   // Octal constant int j = 0397;   // Error: 9 is not an octal digit  To specify a hexadecimal constant, begin the specification with 0x or 0X (the case of the “x” does not matter), followed by a sequence of digits in the range 0 through 9 and a (or A) through f (or F). Hexadecimal digits a (or A) through f (or F) represent values in the range 10 through 15. For example:  int i = 0x3fff;   // Hexadecimal constant int j = 0X3FFF;   // Equal to i  To specify an unsigned type, use either the u or U suffix. To specify a long type, use either the l or L suffix. For example:  unsigned uVal = 328u;             // Unsigned value long lVal = 0x7FFFFFL;            // Long value specified                                    //  as hex constant unsigned long ulVal = 0776745ul;  // Unsigned long value

user: user-2
content: 多补4个0看着舒服点 http://blog.csdn.net/self001/article/details/8060407

user: user-3
content: 原本想帮忙看看来，作为新手的我。发现前辈们以及完美解决，那我能怎么办呢水水水。

user: user-4
content: 引用 2 楼 PKnotnull 的回复:[quote=引用 1 楼 user-5 的回复:] 0x代表这是16进制 我知道16进制0x61是a，0x62是b 为什么前面要加4个零？还有输出的时候是先输出b结果是ba，为什么不是ab？[/quote]  前面的0可以忽略，通常只是为了补齐到8位  顺序反了是因为字节充通常是以小端存储方式，小端怎么存储可以在网上搜索

user: user-0
content: 引用 4 楼 user-5 的回复:(ー_ー)!!我昨天才学到共用体，楼主不要打我 看了下例题，明白了- -！

user: user-0
content: 引用 4 楼 user-5 的回复:(ー_ー)!!我昨天才学到共用体，楼主不要打我 共用同一个内存空间我知道，输出顺序还是不懂 - -！

user: user-5
content: (ー_ー)!!我昨天才学到共用体，楼主不要打我

user: user-5
content: 引用 2 楼 PKnotnull的回复:[quote=引用 1 楼 user-5 的回复:] 0x代表这是16进制 我知道16进制0x61是a，0x62是b 为什么前面要加4个零？还有输出的时候是先输出b结果是ba，为什么不是ab？[/quote] 共用体int i与char用的是同一个内存空间，你输出i的值看下

user: user-0
content: 引用 1 楼 user-5 的回复:0x代表这是16进制 我知道16进制0x61是a，0x62是b 为什么前面要加4个零？还有输出的时候是先输出b结果是ba，为什么不是ab？

user: user-5
content: 0x代表这是16进制