Author Topic: I can't use the C99``  (Read 10413 times)

Offline anxueyiran

  • Single posting newcomer
  • *
  • Posts: 2
I can't use the C99``
« on: October 19, 2010, 03:50:50 pm »
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++;
    }

}



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!!


Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: I can't use the C99``
« Reply #1 on: October 19, 2010, 04:33:34 pm »
How can i use the C99

Please help me ``

Thacks  very much!!

\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 ===|

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

  • Guest
Re: I can't use the C99``
« Reply #2 on: November 18, 2010, 02:27:08 am »

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!!


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