for 循环中的 i++ ++i

 

    for (int i = 0; i < 4; ++i)

c 执行结果一样

 

for i := 0; i <N; ++i {

go 不能编译

 

     1
     2  #include <stdio.h>
     3  int main()
     4  {
     5      int i,j;
     6      i++;
     7      ++j;
     8  }
     1          .file   "loop.c"
     2          .text
     3          .globl  main
     4          .type   main, @function
     5  main:
     6  .LFB0:
     7          .cfi_startproc
     8          endbr64
     9          pushq   %rbp
    10          .cfi_def_cfa_offset 16
    11          .cfi_offset 6, -16
    12          movq    %rsp, %rbp
    13          .cfi_def_cfa_register 6
    14          addl    $1, -8(%rbp)
    15          addl    $1, -4(%rbp)
    16          movl    $0, %eax
    17          popq    %rbp
    18          .cfi_def_cfa 7, 8
    19          ret
    20          .cfi_endproc
    21  .LFE0:
    22          .size   main, .-main
    23          .ident  "GCC: (Ubuntu 11.2.0-19ubuntu1) 11.2.0"
    24          .section        .note.GNU-stack,"",@progbits
    25          .section        .note.gnu.property,"a"
    26          .align 8
    27          .long   1f - 0f
    28          .long   4f - 1f
    29          .long   5
    30  0:
    31          .string "GNU"
    32  1:
    33          .align 8
    34          .long   0xc0000002
    35          .long   3f - 2f
    36  2:
    37          .long   0x3
    38  3:
    39          .align 8
    40  4:

  

posted @ 2022-09-03 10:57  papering  阅读(62)  评论(0编辑  收藏  举报