Thread: Cant see a parse error, but my compiler can

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    8

    Cant see a parse error, but my compiler can

    HI everyone, my compiler says there is a parse error before else, but I dont know what it is? delay is a simple pause function, and the following bit of code is intended to abort a program mid loop by pressing x.

    if ( (ch = getc(stdin)) == 'x')

    break;
    printf("Program aborted. Exiting Program...");
    delay();

    else
    continue;

    Anyone shed some light pls? thanks

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    If you have more than one statement that follows the "if" you need to enclose them in braces { }.

    Like so
    Code:
    if (test)
    {
       Do this;
       And this;
    }
    else
    {
       Do me;
       And me;
    }
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    8
    aha!

    Thanks! It's been a long day.....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I can't get this new compiler to work.
    By Loduwijk in forum C++ Programming
    Replies: 7
    Last Post: 03-29-2006, 06:42 AM
  2. how to call a compiler?
    By castlelight in forum C Programming
    Replies: 3
    Last Post: 11-22-2005, 11:28 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. Help With finding a compiler
    By macman in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 04-15-2005, 08:15 AM
  5. Compiler questions
    By DvdHeijden in forum C++ Programming
    Replies: 6
    Last Post: 01-17-2005, 03:00 PM