Thread: simple syntax error

  1. #1
    Registered User MacNilly's Avatar
    Join Date
    Oct 2005
    Location
    CA, USA
    Posts
    466

    simple syntax error

    Code:
    #include <stdio.h>
    
    int main()
    {
      int x;
      x = 0;
      x = (x ? 1 : 0) /* Error here */
      printf("%d\n", x);
      return 0;
    }
    So... whats the problem?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Missing semicolon on the x = (x?1:0) line...

    --
    Mats

  3. #3
    Registered User MacNilly's Avatar
    Join Date
    Oct 2005
    Location
    CA, USA
    Posts
    466
    Ah I'm a n00b! Maybe someone can delete this thread so I don't look too dumb.

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Don't feel too bad. I've done the same more than once, and often the error message isn't very clear when you do this (because the compiler happily continues on the next line thinking it's fine, but of course gets very confused and eventually errors out - not quite as bad as missing braces tho').

    --
    Mats

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM