An error is reported during I variable initialization in the for loop.

Source: Internet
Author: User

GCC version: GCC version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)

The source file of the program written is 643b. C,

In this file, there is a statement: For (INT I = 0; I <11; I ++)

Run the compilation command: gcc-O 643b 643b. c

An error is reported:

643b. C: In function 'main ':
643b. C: 5: 2: Error: 'for' loop initial declarations are only allowed in c99 Mode
For (INT I = 0; I <11; I ++)
^
643b. C: 5: 2: Note: Use Option-STD = c99 or-STD = gnu99 to compile your code

You need to add the parameter-STD = c99 or-STD = gnu99 to the command line.

Gcc-O 643b 643b. C-STD = c99

Run the program:./643b

Expected result:

I am happy

Or:

Gcc-O 643b 643b. C-STD = gnu99

Run the program:./643b

Expected result:

I am happy

The cause of the error may be that the initialization in the for loop can only be performed in the standard c99 or gnu99.

Defines the type of I, so you need to add the parameter:-STD = c99 or-STD = gnu99


An error is reported during I variable initialization in the for loop.

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.