Why is the for (int i=0;i<9;i++) error in the C language?

Source: Internet
Author: User
The display indicates that I variables cannot be defined in for and must be defined outside, which is why?

Because the previous C standard of the C99 standard is not supported for temporary variables defined in the For loop.

The C99 standard supports such writing. However, there are some compilers that are not ready to support the C99 standard, or are compiled in C89 mode by default.

If you are using visual c++6.0, then there is no way, the goods have stopped updating, it is impossible to support C99.

If you are using a gcc compiler (v3.0 or more), the default is to compile by C89. Manual compilation with-std=c99 on the line can be compiled according to C99 Standard, the above to write no problem. Like what:

Gcc-std=c99 Tset.c-o Test

If you use the GCC compiler's codeblocks, you know how to make it default to automatically compile with the C99 standard:

Settings-Compiler and debugger ...

Open the Compile Debug Settings panel and add-std=c99 to the other options in the global compiler settings item.

Other Ides that use GCC should be able to set this.

But the proposal or according to C89 writing, many places written C99 standard will go wrong, who told them not to buy C99 account.

After modification:



Why is the for (int i=0;i<9;i++) error in the C language?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.