C语言数组下标为何从0开始
来源:互联网 发布:老司机网络意思是什么 编辑:程序博客网 时间:2024/04/27 17:31
Many other features, besides the type system, were put in C for the C compiler-writer's benefit (and
why not, since C compiler-writers were the chief customers for the first few years). Features of C that
seem to have evolved with the compiler-writer in mind are:
• Arrays start at 0 rather than 1. Most people start counting at 1, rather than zero. Compilerwriters
start with zero because we're used to thinking in terms of offsets. This is sometimes
tough on non-compiler-writers; although a[100] appears in the definition of an array, you'd
better not store any data at a[100], since a[0] to a[99] is the extent of the array.
说白了就是除了类型系统之外,C的许多特征是为了方便编译器设计者而建立的(为什么不呢?开始几年C语言的主要客户就是哪些编译器设计者).数组下标从0而不是从1开始也是根据编译器设计者的思路而来的,因为偏移量的概念在他们心中已是根深蒂固.但这种设计让非编译器设计者感觉很别扭,他们可能会在一个定义的a[10]的a[10]存储数据,导致有名的一位偏移(one-bit offset)错误.
java为何下标也从0开始呢,估计是考虑到习惯性问题.C/C++程序员被固化成下标从0开始后,想更改它也是件费劲事.
- C语言数组下标为何从0开始
- C语言数组元素下标为何从0开始
- 数组下标从0开始
- C++/JAVA 的数组下标为什么从0开始
- 数组的下标从0开始
- 数组下标为什么要从0开始
- 数组下标为什么是从0开始?
- Python之父:为什么Python数组下标从0开始
- 发掘数组下标从0开始的缘由
- c语言数组下标问题
- C语言数组下标是负数
- C语言数组下标太大怎么办?
- 论C语言中的数组下标越界
- C语言允许数组下标是负数
- (c语言)指针和数组下标
- smarty中 下标不是从0开始的一维数组 用foreach读取
- 数组操作-将下标变成从0开始的连续数字
- 程序风格---数组下标全部从1开始
- 招技术人才,试试iTechTag
- sql 常用语句积累
- JS的飘动窗口特效
- 用spring、Hibernate、Struts组建轻量级架构
- 从后台写向前台并执行 innerHTML
- C语言数组下标为何从0开始
- flash as3的单选框RadioButtonGroup的使用
- J2EE架构的6个最佳实践
- 开博第一篇
- LFS中又碰到的问题&解决
- 看到两句经典台词
- CSS+JS完成下拉菜单
- 谈虚拟内存与物理内存的关系
- Oracle中的Union、Union All、Intersect、Minus