Meaning of compiler diagnostic: "primary expression before else"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ogkid101
    New Member
    • Oct 2008
    • 1

    Meaning of compiler diagnostic: "primary expression before else"

    hi there!!
    i am trying to find out what are primary expressions and also can u help me on on the following line in this C program where the compiler is telling me that a primary expression before else?:

    if ( x > 500);
    {
    printf (" %d months *** ", x);
    }

    else
    printf (" %d months", x);
  • boxfish
    Recognized Expert Contributor
    • Mar 2008
    • 469

    #2
    Try getting rid of the semicolon after if ( x > 500). The compiler thinks it's an empty statement, meaning do nothing.
    Hope this helps.

    Please use code tags around your code. Put [CODE] before it and [/CODE] after it so it shows up in a code box and the indentation isn't wrecked. Thanks.

    Comment

    • curiously enough
      New Member
      • Aug 2008
      • 79

      #3
      Originally posted by boxfish
      Please use code tags around your code. Put [CODE] before it and [/CODE] after it so it shows up in a code box and the indentation isn't wrecked. Thanks.
      DON'T DO THAT, IT WILL GET DELETED IMMEDIATELY! CODE TAGS ARE A TRAP MODERATORS USE!

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Originally posted by curiously enough
        DON'T DO THAT, IT WILL GET DELETED IMMEDIATELY! CODE TAGS ARE A TRAP MODERATORS USE!
        ogkid101 please ignore what curiously enough says here and do use code tags they make your code easier to read.

        What curiously enough is referring to is the rule against posting a full code solution. You need not worry about this as you have not even told us what your full solution is meant to do let alone posted it. Posting a single if statement like that is perfectly OK.

        The title of your thread leaves a lot to be desired though and I am renaming this thread to have a better name.

        Please read our posting guidelines.

        curiously enough you may wish to re-read the guidelines too, posting in all capital letters is a warnable (and therefore banable) breaking of the guidelines. Not that I am doing either in this case.

        Comment

        Working...