c++确定数组长度

使用sizeof

在Dev c++下调试

#include <iostream.h>
int main()
{
     
static int a[]={1,2,4,8,16};
     
for(int i=0;i<(sizeof(a)/sizeof(int));i++)
     cout 
<< a[i] << " ";
     cout 
<< endl;
}

 

 

posted @ 2010-03-10 09:27  doze  阅读(430)  评论(0)    收藏  举报