小编Man*_*dhu的帖子

运算符大小反转行为

我们知道,当我们使用数组时,它保存第一个元素的地址,而&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)

\我不明白为什么请解释

c sizeof

4
推荐指数
1
解决办法
132
查看次数

对于c程序中的循环混淆

为什么循环从2运行到7?

int i;    
for(i=1;i<=6;printf("\n%d\n",i))    
i++;
Run Code Online (Sandbox Code Playgroud)

这个的输出是

2
3
4
5
6
7
Run Code Online (Sandbox Code Playgroud)

但限制i是6.

c for-loop

2
推荐指数
1
解决办法
111
查看次数

标签 统计

c ×2

for-loop ×1

sizeof ×1