我们知道,当我们使用数组时,它保存第一个元素的地址,而&array是存储整个数组地址,当我在printf中使用它时为true,但在sizeof运算符中,这是相反的行为,为什么
我在Windows 7上使用带有GCC的代码块
int main(void)
{
int c[5];
printf(" %d %d %d %d\n",c,c+1,&c,&c+1);\\when we add 1 in "c" it add more 4 bytes and when "&c+1" it add 20 byte witch is true
printf(" %u %u ",sizeof(c),sizeof(&c));\\But when we print first element size (with "c") it give 20 byte and when print (With "&c") whole arry size it give 4 byte
return 0;
}
Run Code Online (Sandbox Code Playgroud)
\我不明白为什么请解释
为什么循环从2运行到7?
int i;
for(i=1;i<=6;printf("\n%d\n",i))
i++;
Run Code Online (Sandbox Code Playgroud)
这个的输出是
Run Code Online (Sandbox Code Playgroud)2 3 4 5 6 7
但限制i是6.