posts - 134,comments - 22,trackbacks - 0
#include<stdio.h> 
int main() 

    
char x,y,z; 
    
int i; 
    
int a[16]; 
    
    
for(i=0;i<=16;i++
    

        a[i]
=0
        printf(
"1\n"); 
    }
 
    
return 0
}

由于函数内部的局部变量是从栈的高地址向低地址分配.
i=16时,数组下标溢出,a[i]引用的其实是i变量,这样,上述循环成为一个死循环。
posted on 2010-06-03 13:06 何克勤 阅读(334) 评论(0)  编辑  收藏 所属分类: Algorithm and Data Structure

只有注册用户登录后才能发表评论。


网站导航: