Thread: yet another unexplainable flaw

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    14

    yet another unexplainable flaw

    Code:
    struct database
    {
      int id_number;
      int age;
      float salary;
    };
    int main()
    {
      database employee;  //There is now an employee variable that has modifiable 
    			    //variables inside it.
      employee.age=22;
      employee.id_number=1;
      employee.salary=12000.21;
    }
      database boss;
      boss.age=20
      boss.id_number=2
      boss.salary=100000
    }
    I get a 'syntax error before .' on line boss.age=20
    However, I can't seem to find out how to fix it.

  2. #2
    Registered User HaLCy0n's Avatar
    Join Date
    Mar 2003
    Posts
    77
    You have an extra } in there that you never opened. You also forgot semicolons on the last 3 lines of assignments.

  3. #3
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511
    You have too many } braces you only need one for main

    int main()


    {






    }
    Mr. C: Author and Instructor

  4. #4
    Registered User
    Join Date
    Jun 2003
    Posts
    14
    Code:
    struct database
    {
      int id_number;
      int age;
      float salary;
    };
    int main()
    {
      database employee;  //There is now an employee variable that has modifiable 
    			    //variables inside it.
      employee.age=22;
      employee.id_number=1;
      employee.salary=12000.21;
    }
    {
      database boss;
      boss.age=20;
      boss.id_number=2;
      boss.salary=100000;
    }
    There, changed it. But it still gives errors!

  5. #5
    Registered User
    Join Date
    Jun 2003
    Posts
    14
    thx it works now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Design flaw in C++?
    By @nthony in forum C++ Programming
    Replies: 24
    Last Post: 10-20-2008, 07:47 PM
  2. Replies: 18
    Last Post: 12-31-2005, 01:56 PM
  3. IE flaw threat hits the roof
    By axon in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-16-2005, 11:29 AM
  4. MAJOR security flaw in xp!!
    By RoD in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 02-17-2003, 07:14 AM
  5. Major XP secuirity flaw
    By Driveway in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 09-10-2002, 06:48 PM