Thread: C99 mode??

  1. #1
    C(++)(#)
    Join Date
    Jul 2004
    Posts
    309

    C99 mode??

    The following code:
    Code:
    void quest_one()
    {
        char* guess;
        for (int a = 0; a<25; a++)
        {
            printf("\n");
        }
        printf(QOne->Desc);
        guess = getchar();
        char* answer;
        answer = "void";
        if(guess != answer)
        {
            printf("\nIncorrect, you lose!");
        }
        else if(guess == answer)
        {
            printf("congrats, you roxors!");
        }
    }
    keeps giving me the vague error of: For loop declared outside of C99 mode. What am I doing wrong?

    EDIT: Perhaps somebody could also explain what C99 mode is? I've never heard of that before
    Last edited by 7smurfs; 03-23-2005 at 02:56 PM.
    To code is divine

  2. #2
    customized user title!
    Join Date
    Mar 2005
    Posts
    24
    It's giving you that error because you're delcaring a variable inside the for loop, which is not part of the C99 standard(I think).

  3. #3
    C(++)(#)
    Join Date
    Jul 2004
    Posts
    309
    Heh, thanks. Figures, I thought I tried that...
    To code is divine

  4. #4
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    The way he's declaring the counter is part of C99. The OP is getting the error because he's not in C99 compatibility mode. There's some way of telling the compiler that you want to compile it with C99 standards, I'm sure. In gcc for instance, you add the option --std=c99
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. console mode and service mode
    By George2 in forum C# Programming
    Replies: 0
    Last Post: 06-01-2008, 01:42 AM
  2. My first game
    By homeyg in forum Game Programming
    Replies: 20
    Last Post: 12-22-2004, 05:25 PM
  3. Implementing "ls -al"
    By pdstatha in forum Linux Programming
    Replies: 11
    Last Post: 03-20-2002, 04:39 AM
  4. free() usage
    By pdstatha in forum C Programming
    Replies: 5
    Last Post: 03-13-2002, 09:28 AM
  5. Implementing "ls -al"
    By pdstatha in forum C Programming
    Replies: 7
    Last Post: 03-06-2002, 05:36 PM