为什么int 070在C程序中的输出是56?
Why output of int 070 is 56 in C program?
你能解释一下吗?为什么它给出 56 值作为输出?
#include <stdio.h>
#include <conio.h>
void main()
{
int x = 070;
printf("%d", x);
getch();
}
任何以 0
开头的整数文字(整数常量)是一个 octal representation.
引用 C11
,章节 §6.4.4.1,整数常量
octal-constant:
0
octal-constant octal-digit
和
octal-digit: one of
0 1 2 3 4 5 6 7
并且,根据第 §7.21.6.1 章,对于 %d
格式说明符 printf()
,(强调我的 )
d,i
The int
argument is converted to signed decimal [...]
你能解释一下吗?为什么它给出 56 值作为输出?
#include <stdio.h>
#include <conio.h>
void main()
{
int x = 070;
printf("%d", x);
getch();
}
任何以 0
开头的整数文字(整数常量)是一个 octal representation.
引用 C11
,章节 §6.4.4.1,整数常量
octal-constant:
0
octal-constant octal-digit
和
octal-digit: one of
0 1 2 3 4 5 6 7
并且,根据第 §7.21.6.1 章,对于 %d
格式说明符 printf()
,(强调我的 )
d,i
Theint
argument is converted to signed decimal [...]