#include<bits/stdc++.h>
using namespace std;
int fun()
{
int d = 0012;
return d;
}
int main()
{
cout << fun() << "\n";
return 0;
}输出: 10
这里的fun()函数d值是12,但是当调用fun()并输出它的值时,它是10,为什么fun()函数返回10?
发布于 2021-09-29 14:30:31
因为1*8+2 = 10。
您的数字以0开头,这意味着它是八进制的。
Backus Naur形式是这样的:
ISO/IEC 9899:TC2
6.4.4 Constants
Syntax
integer-constant:
decimal-constant integer-suffixopt
octal-constant integer-suffixopt
hexadecimal-constant integer-suffixopt
octal-constant:
0
octal-constant octal-digit
octal-digit: one of
0 1 2 3 4 5 6 7https://stackoverflow.com/questions/69378355
复制相似问题