Thread: Syntax error before '=' token

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    1

    Syntax error before '=' token

    Hello. I'm doing a program for university using structs. Altough i've come up with a problem and i cannot figure out what i'm doing wrong. ANy help would be apreciatted.

    Here's the piece of code that doesnt compile

    Code:
    struct espectaculo
    {
    char nomedoespectaculo[50];
    int salaocupada=0;
    int dia;
    int mes;
    int ano;
    }espectaculo[31];
    If i take out the = and dont initialize the variable there's no problem at all and the program runs just fine. Any tips?

  2. #2
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    When you are defining a struct, you cannot init the data. You do that at variable definition time (if you want).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what am I missing? (Program won't compile)
    By steals10304 in forum C Programming
    Replies: 3
    Last Post: 08-25-2009, 03:01 PM
  2. more then 100errors in header
    By hallo007 in forum Windows Programming
    Replies: 20
    Last Post: 05-13-2007, 08:26 AM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM