c - K&R C 处理八进制

标签 c octal kernighan-and-ritchie

所以,首先我阅读了以下内容: http://www.hpc.unimelb.edu.au/nec/g1af02e/chap1.html它告诉我以下内容:

K&R C and SUPER-UX K&R C The digits 8 and 9 are allowed. They are considered decimal integer constants.

我有点困惑...寻找更多...发现这个:http://docs.oracle.com/cd/E19205-01/819-5265/bjbfb/index.html

它告诉我:

Accepts 8 or 9 in octal escape sequences.

但是,根据:http://en.wikipedia.org/wiki/Octal

The octal numeral system, or oct for short, is the base-8 number system, and uses the digits 0 to 7.

现在我真的很困惑。我从来没有机会真正使用 K&R C 编译器……那么为什么 K&R C 接受 8 和 9 作为八进制数字……这是如何处理的?它们在“真正的”八进制系统中的值(value)是什么?

最佳答案

K&R C 不是很严格,所以很多 ANSI-C(和更新的)编译器不允许的东西都被允许了。

“八进制”数字 0193 相当于 1*8^2 + 9*8^1 + 3。可憎之物?是的。

关于c - K&R C 处理八进制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19901347/

相关文章:

c - 程序可以编译,但在提供输入时不执行任何操作

c++ - 使用指针将 2 个矩阵相乘

c++ - 如何使用动态内存分配将十进制转换为八进制?

c - K 和 R C 编程练习 1-19

c - 我应该如何学习C?

r - 反斜杠转义数字 '\1' 到 '\7' 在 R 字符串中意味着什么,为什么它们比较错误?

python - 将 Levenshtein 比率转换为 C++

c - CodeBlocks IDE 中的 C 语言中的 Scanf 函数有问题吗?

c++ - 如何修复该程序中的错误以及为什么我会收到它?

python-2.7 - 如何在 Python 中解析具有八进制值的 char 数组?