Thread: Parse error before "if"

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    6

    Angry Parse error before "if"

    I am very new to C++ and learning from the tutorials on cprogramming.com, until I can't get a book. I am on the 2nd tutorial on my 2nd day, and I had this error message when trying out an "if" statement.

    parse error before "if"

    ---------------------
    here is my code
    ---------------------

    #include <iostream.h>
    int main()

    if (TRUE)
    {
    cout<<(4>=4);
    }


    ------------------

    Thanks if you can help, and thanks if you can't.

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    66
    1. please read the sticky posts about using code tags in your questions.

    2. C/C++ are case sensitive 'TRUE' is not the same as 'true'

    you want to do:

    Code:
     if (true) {
     ...
    }

  3. #3
    Registered User
    Join Date
    Jun 2002
    Posts
    6
    Alright, I will, thanks though, in the tutorial I misread it.
    Thanks alot.

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    559
    You also need braces for your functions, including main
    Code:
    int main()
    {
       ...code here...
       return 0;
    }
    Truth is a malleable commodity - Dick Cheney

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Interpreter.c
    By moussa in forum C Programming
    Replies: 4
    Last Post: 05-28-2008, 05:59 PM
  2. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 05:45 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM