gpt4 book ai didi

c - 奇怪的 printf 行为?

转载 作者:太空宇宙 更新时间:2023-11-04 06:09:05 25 4
gpt4 key购买 nike

<分区>

[cprg]$ cat test.c
#include <stdio.h>
#include <stdlib.h>

int main(int argc,char *argv[])
{
int i=10;
printf("i=%d\ni++=%d\n++i=%d\n",i,i++,++i);
return 0;
}
[cprg]$ make
gcc -g -Wall -o test test.c
test.c: In function ‘main’:
test.c:7: warning: operation on ‘i’ may be undefined
test.c:7: warning: operation on ‘i’ may be undefined
[cprg]$ ./test
i=12
i++=11
++i=12

我不知道为什么会这样。请任何人都可以详细解释一下这里发生了什么?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com