下面的代碼輸出什麼?
#include
int main(void)
{
int i;
int a[5];
for (i = 0; i <= 5; ++i) {
a[i] = -i;
printf("a[%d] = %d\n", i, a[i]);
}
return 0;
}
#include<stdio.h>
void main()
{
int i=0;
int a[5]={0,0,0,0,0};
for (i = 0; i <= 5; i++) {
a[i] = -i;
printf("a[%d] = %d\n", i, a[i]);
if(i==4){
printf("%p\n",&i);
printf("%p\n",&a[0]);
printf("%p\n",&a[1]);
printf("%p\n",&a[2]);
printf("%p\n",&a[3]);
printf("%p\n",&a[4]);
while(1);
}
}
}
運行結果: