My Fifteen code won't compile because of these two "expected expression" errors in my "won" section.

 fifteen.c:254:15: error: expected expression
   while (n !== d*d)  
 fifteen.c:265:20: error: expected expression
2 errors generated.

Here's the framework of the code (omitting closing }s to save space here. Hope posting this helps & is OK re academic honesty:

         int i;
        int j;
        int d;
        int n = 1;

   while (n != d*d)  
        for (i = 0)
            for ()
                while (board[i][j])

                       return false; 


Alexandros' suggestion (below) eliminates the first error mess

I'd appreciate any advice.

  • Please copy the entire error message into your post (use the "edit" link under the tags), highlight it with the mouse in the edit window, and press CTRL + K to format it as code. This will make it much easier to read. – Air Oct 10 '14 at 22:16
  • I am afraid you will need to provide more code. Is it possible that you provide the entire if statement that corresponds to that else? I am not used to clang error descriptions. It seems though that your error is similar to the one produced in the while loop condition mistake. For some reason clang expects an expression rather than an else. Check the code above or provide some more code please. – Alexandros Andreou Oct 11 '14 at 0:29

You are using a comparison symbol that does not exist. Change !== with != and that should do the work for the while statement. About the else I can't really help without some more information... Did you open close your braces correctly? Please post the code section if possible.

Good Luck!

Edit: ok this is clear now. The while statement has no else branch. The else branch only optionally exists in the if statement so please reconsider your logic. Also please reconsider your for loops as they are rarely used in any other form than

for (initialisation; condition; increment)
  • That did it! I eliminated the while statement (basically replaced it with an if) and it compiles. I will take your advice and reconsider logic & loops. Thanks for your help. – Robert Feduniak Oct 11 '14 at 17:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .