switch case/structure...

This is a discussion on switch case/structure... within the C++ Programming forums, part of the General Programming Boards category; Well, I'm having some problems: code extract: Code: switch(race) { case 'O': { stats.fp=40; stats.dp=35; stats.speed=3; break; } case 'E': ...

  1. #1
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942

    switch case/structure...

    Well, I'm having some problems:

    code extract:
    Code:
        switch(race)
        {
            case 'O':
            {
                    stats.fp=40;
                    stats.dp=35;
                    stats.speed=3;
                    break; 
            }                     
            case 'E':
            {
                    stats.fp=30;
                    stats.dp=30;
                    stats.speed=30;
                    break;  
            }        
            case 'H':
            {
                    stats.fp=35;
                    stats.dp=25;
                    stats.speed=30;
                    break; 
            }
    the compiler problems are all
    parse error before '.' token
    on the lines after the { in each switch case

    Code:
    struct stats
    {
        int fp;
        int dp;
        int speed;
    };
    Here is my structure

  2. #2
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942
    Alright. Thanks. I've never used structures before. I just thought they might come in handy :P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. ascii rpg help
    By aaron11193 in forum C Programming
    Replies: 18
    Last Post: 10-29-2006, 01:45 AM
  3. Switch
    By cogeek in forum C Programming
    Replies: 4
    Last Post: 12-23-2004, 06:40 PM
  4. Switch Case
    By FromHolland in forum C++ Programming
    Replies: 7
    Last Post: 06-13-2003, 04:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21