user-0 提问: 新人学习，有些不懂，还请大佬指教。

回复:
user: user-1
content: 第一张图给你答案了，格式不同

user: user-2
content: 不好意思，EBCDIC 里的1个字节需要 8个 bit 才能与ASCII 里 7个bit表示的字符对应上。ASCII 里 7个bit 已经可以表示常用的128个字符（包括不可见的控制字符），用8个bit 则可以表示扩展后的更多字符，具体你可以百度等搜索。ASCII 与 EBCDIC 的转换编码表你可以百度 IBM 的网站。

user: user-2
content: 1 个bit 就像1 盏灯，有灭和亮两种状态，用数字表示，可以定义为 0 和 1.  2 个bit 就像2 盏灯，每盏灯有灭和亮两种状态，用数字表示，可以定义为 0 和 1，组合如下：   1#灯  2#灯   0     0   0     1   1     0   1     1  4个状态可以表示4个意思、4个人物等。如你可以定义 00 表示赵一，01表示 钱二，10表示 张三，11表示 李四  3 个bit 就像3 盏灯，每盏灯有灭和亮两种状态，用数字表示，可以定义为 0 和 1，组合如下：   1号灯  2号灯  3号灯 代表含义例如：   0      0      0     我   0      0      1     爱   0      1      0     你   0      1      1     塞   1      0      0     北   1      0      1     的   1      1      0     雪   1      1      1     !  8个状态可以表示8个意思，例如上面的7个字和1个标点，如果你和你女朋友约定好了这些代表含义，你用3 盏灯的8个灭和亮的组合就可以向女朋友传递8个字符的信号。  ... 7 个bit 就像7 盏灯，每盏灯有灭和亮两种状态，用数字表示，可以定义为 0 和 1，总共有2的7次方即128种组合。 用数字表示，可以表达 0 -- 127 。这128个数字用来表达英语里的字母（大写26个、小写26个）、数字字符（0-9）、标点符号(就是我们键盘上常见的) 就足够了。那么哪个数字表示 大写字母 A，哪个数字代表 小写字母 a 呢？不同的人可以做出不同的规定（王八的屁股——规定，没有什么道理可讲）。其中有两个著名的规定： 1）美国国家标准学会(American National Standard Institute , ANSI )制定的ASCII(American Standard Code for Information Interchange，美国信息交换标准代码） 2）IBM 公司制定的 EBCDIC(Extended Binary Coded Decimal Interchange Code，广义二进制编码的十进制交换码）  在 ASCII 里，65代表大写字母 A，97代表小写字母 a。其它的你可以百度等搜索。 在 EBCDIC里，193代表大写字母 A，129代表小写字母 a。其它的你可以百度等搜索。  在 C 语言里，规定（王八的屁股——规定，没有什么道理可讲）char字符在内存里用当前操作系统的编码（ASCII或EBCDIC）的对应值表示，所以在 DOS/WINDOWS/LINUX 等 ASCII 编码的操作系统里，C 语言的 cChar1='a' 和 cChar2=97 两个字符在内存里的值都是 97.但是在IBM AS/400小型计算机或 ES/9000 大型计算机的 OS/400 等操作系统里，C 语言的 cChar1='a'在内存里的值是129，和97的cChar2 不同。 此书的作者可能没有用过 IBM 的小型计算机或大型计算机，不了解 EBCDIC编码。 书上的例子在 Windows 下运行，结果当然是对的。

user: user-3
content: 字符型变量和整数变量在内存中都是一样的，只是范围问题而已，你百度ascii.  char xxx = 'a'; 这句的含义是xxx存储的是'a'的ascii表对应的数字. %c解释成字符类型，%d解释成数字类型

user: user-4
content: 话说，好歹也把代码敲一遍啊，提问的时候COPY上来啊。如果你这么喜欢拍照，我希望你多上传点美女。

user: user-5
content: 你应该先学学怎么提问

user: user-6
content: Format Specification Fields: printf and wprintf Functions A format specification, which consists of optional and required fields, has the following form:  %[flags] [width] [.precision] [{h | l | I64 | L}]type  Each field of the format specification is a single character or a number signifying a particular format option. The simplest format specification contains only the percent sign and a type character (for example, %s). If a percent sign is followed by a character that has no meaning as a format field, the character is copied to stdout. For example, to print a percent-sign character, use %%.  The optional fields, which appear before the type character, control other aspects of the formatting, as follows:  type  Required character that determines whether the associated argument is interpreted as a character, a string, or a number (see Table R.3).  flags  Optional character or characters that control justification of output and printing of signs, blanks, decimal points, and octal and hexadecimal prefixes (see Table R.4). More than one flag can appear in a format specification.  width  Optional number that specifies the minimum number of characters output. (See printf Width Specification.)   precision  Optional number that specifies the maximum number of characters printed for all or part of the output field, or the minimum number of digits printed for integer values (see Table R.5).  h | l | I64 | L  Optional prefixes to type-that specify the size of argument (see Table R.6). printf Type Field Characters The type character is the only required format field ; it appears after any optional format fields. The type character determines whether the associated argument is interpreted as a character, string, or number. The types C and S, and the behavior of  c and s with printf functions, are Microsoft extensions and are not ANSI-compatible.   Table R.3   printf Type Field Characters  Character Type Output Format  c int or wint_t When used with printf functions, specifies a single-byte character; when used with wprintf functions, specifies a wide character.  C int or wint_t When used with printf functions, specifies a wide character; when used with wprintf functions, specifies a single-byte character.  d int Signed decimal integer.  i int  Signed decimal integer.  o int  Unsigned octal integer.  u int  Unsigned decimal integer.  x int Unsigned hexadecimal integer, using “abcdef.”  X int Unsigned hexadecimal integer, using “ABCDEF.”  e  double Signed value having the form [ – ]d.dddd e [sign]ddd where d is a single decimal digit, dddd is one or more decimal digits, ddd is exactly three decimal digits, and sign is + or –.  E double Identical to the e format except that E rather than e introduces the exponent.  f double Signed value having the form [ – ]dddd.dddd, where dddd is one or more decimal digits. The number of digits before the decimal point depends on the magnitude of the number, and the number of digits after the decimal point depends on the requested precision.  g double Signed value printed in f or e format, whichever is more compact for the given value and precision. The e format is used only when the exponent of the value is less than –4 or greater than or equal to the precision argument. Trailing zeros are truncated, and the decimal point appears only if one or more digits follow it.  G double Identical to the g format, except that E, rather than e, introduces the exponent (where appropriate).  n  Pointer to integer  Number of characters successfully written so far to the stream or buffer; this value is stored in the integer whose address is given as the argument.  p Pointer to void Prints the address pointed to by the argument in the form xxxx:yyyy where xxxx is the segment and yyyy is the offset, and the digits x and y are uppercase hexadecimal digits.  s String  When used with printf functions, specifies a single-byte–character string; when used with wprintf functions, specifies a wide-character string. Characters are printed up to the first null character or until the precision value is reached.  S String When used with printf functions, specifies a wide-character string; when used with wprintf functions, specifies a single-byte–character string. Characters are printed up to the first null character or until the precision value is reached.

user: user-7
content: int printf(const char *format, ...) 函数把输出写入到标准输出流 stdout ，并根据提供的格式产生输出。  format 可以是一个简单的常量字符串，但是您可以分别指定 %s、%d、%c、%f 等来输出或读取字符串、整数、字符或浮点数。还有许多其他可用的格式选项，可以根据需要使用。如需了解完整的细节，可以查看这些函数的参考手册。

user: user-0
content: 引用 5 楼 冷风1023的回复:存储都是一样的，打印出不同，是因为打印的格式不一样。 printf("%c\n",int1); printf("%d\n",int2); 那，这两种打印格式分别什么意思？

user: user-7
content: 存储都是一样的，打印出不同，是因为打印的格式不一样。 printf("%c\n",int1); printf("%d\n",int2);

user: user-8
content: 字符a的ascii值为97，所以你得到的值为97. 你把数字或者字母换了，你就得到不一样的值和字符，这样好理解一点。