i 为啥等于5
#include"stdio.h"main()
{
int i ;
for(i=1;i++<4;);
printf("%d",i);
程序代码:
root@~ #gcc --version
gcc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root@~ #cat 23.c
#include <stdio.h>
int main (void) {
int i;
for(i=1;i++<4;); //楼主这里的代码有分号,也即当i++以后没有执行for没有正确执行
printf("%i\n",i);
for(i=1;i++<4;) //假设是这样的话,最后i的结果就是4
printf("%i\n",i);
return 0;
}
root@~ #./23
5
2
3
4
root@~ #