c/c++语言开发共享将此代码行转换为C.

我有以下代码行:

for ( int i = index; i size; ++i ) //i,index and size are integers.al is an arraylist 

当我在C中编译它时,我得到错误:

  'for' loop initial declarations are only allowed in C99 mode 

我不知道如何解决这个问题。

谢谢!

    在循环之外声明迭代器:

     int i; for (i = index; i < al->size; ++i) { do_foo(); } 

    或者如果您的编译器支持它,请根据c99或兼容标准进行编译:

     gcc -std=c99 your_code.c 

    (注意gnu89 / gnu90是默认值(从4.8开始,无论如何。))

    只需在循环之前声明int i

    尝试先声明i变量。

     int i; for ( i = index; i < al->size; ++i ) 

     for ( int i = index; i < al->size; ++i ) 

    需要成为

     int i; for (i = index; i < al->size; ++i) 

      以上就是c/c++开发分享将此代码行转换为C.相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/c-cdevelopment/519275.html

      (0)
      上一篇 2020年12月5日
      下一篇 2020年12月5日

      精彩推荐