User forums > Using Code::Blocks

I can't use the C99``

(1/1)

anxueyiran:
EG:


--- Code: ---#include<stdio.h>
int main()
{
    int Q1=2,Q,N,a[20];
    scanf("%d",&N);
    while(1)
    {
        int j=0,sum=1;
        Q=Q1;
        while(Q>0)
        {
            a[j++]=Q%10;
            Q=Q/10;
        }
        for(int i=0;i<j;i++)   // 15
        {
            sum=sum*a[i];
        }
        if(sum==N)
        {
            printf("%d\n",Q1);
            break;
        }
        Q1++;
    }

}
--- End code ---



BUT:

\a.c||In function 'main':|
\a.c|15|error: 'for' loop initial declarations are only allowed in C99 mode|
\a.c|15|note: use option -std=c99 or -std=gnu99 to compile your code|
||=== Build finished: 1 errors, 0 warnings ===|


How can i use the C99

Please help me ``

Thacks  very much!!

Ceniza:

--- Quote from: anxueyiran on October 19, 2010, 03:50:50 pm ---How can i use the C99

Please help me ``

Thacks  very much!!

--- End quote ---


--- Quote from: anxueyiran on October 19, 2010, 03:50:50 pm ---\a.c||In function 'main':|
\a.c|15|error: 'for' loop initial declarations are only allowed in C99 mode|
\a.c|15|note: use option -std=c99 or -std=gnu99 to compile your code|
||=== Build finished: 1 errors, 0 warnings ===|

--- End quote ---

It is in the compiler options.

Please have in mind that your question is specific to the compiler you are using (which, from the error message, looks like it is GCC), so it is not specific to Code::Blocks. In other words, the question does not really belong here.

Alfons_Silver:

--- Quote from: anxueyiran on October 19, 2010, 03:50:50 pm ---
BUT:

\a.c||In function 'main':|
\a.c|15|error: 'for' loop initial declarations are only allowed in C99 mode|
\a.c|15|note: use option -std=c99 or -std=gnu99 to compile your code|
||=== Build finished: 1 errors, 0 warnings ===|


How can i use the C99

Please help me ``

Thacks  very much!!


--- End quote ---

in Code::Blocks 10.05 you can define the c99 standart in :
Settings=>Compiler_and_debugger..=>Global_Compiler_settings=>Other_options

write there => -std=c99
good luck

Navigation

[0] Message Index

Go to full version