help! - 'cxx0030:expression cant be evaluated.'

This is a discussion on help! - 'cxx0030:expression cant be evaluated.' within the C++ Programming forums, part of the General Programming Boards category; Hello all, I get the feeling I'm doing something really simple wrong here, personally, I think its a matter of ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    3

    Exclamation help! - 'cxx0030:expression cant be evaluated.'

    Hello all, I get the feeling I'm doing something really simple wrong here, personally, I think its a matter of scope, but I cant seem to find the problem if it is, anyway, heres my code, and im hopeing someone will take the time to peruse it real quik for me. In this block of code, the integer variable 'killer' causes a run time error and crashes the program. If someone want the entirety of the code, as I have left out most of the extemporaneous crap code that doesnt relate to this problem, let me know and i'll post it. Anyway, Im at my wits end......thank you for your time.

    ************************************************** **

    -#includes and stuff up here-

    int randMon(int location) {
    int beastPos[9] = {0};
    switch(location) {
    case 0:
    beastPos[0] = 0;
    beastPos[1] = 0;
    beastPos[2] = 0;
    beastPos[3] = 0;
    beastPos[4] = 0;
    beastPos[5] = 0;
    beastPos[6] = 0;
    beastPos[7] = 1;
    beastPos[8] = 1;
    beastPos[9] = 1;
    break;
    case 1:
    beastPos[0] = 0;
    beastPos[1] = 0;
    beastPos[2] = 0;
    beastPos[3] = 0;
    beastPos[4] = 0;
    beastPos[5] = 1;
    beastPos[6] = 1;
    beastPos[7] = 1;
    beastPos[8] = 1;
    beastPos[9] = 1;
    break;
    case 2:
    beastPos[0] = 3;
    beastPos[1] = 3;
    beastPos[2] = 3;
    beastPos[3] = 3;
    beastPos[4] = 3;
    beastPos[5] = 6;
    beastPos[6] = 6;
    beastPos[7] = 6;
    beastPos[8] = 6;
    beastPos[9] = 6;
    break;
    case 3:
    beastPos[0] = 9;
    beastPos[1] = 9;
    beastPos[2] = 9;
    beastPos[3] = 9;
    beastPos[4] = 9;
    beastPos[5] = 9;
    beastPos[6] = 3;
    beastPos[7] = 3;
    beastPos[8] = 6;
    beastPos[9] = 6;
    break;
    };
    int fightMe = beastPos[(rand() % 10)];
    return fightMe;
    };

    int main() {
    srand(time(0));
    int anumber = (rand() % 4);
    int killer = randMon(anumber);
    return 0;
    }
    ************************************************** **

    help!!!! =)

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    int beastPos[9] = {0};

    should be:

    int beastPos[10] = {0};

    as arrays start at element 0.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    3
    ok, did that, still have same problem......thank you though for catching that, I knew that, just slipped past me

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    3
    nope, wait, check that......different problem...thank you very much, that helped.....
    thank you again.

  5. #5
    Unregistered
    Guest
    switch (...)
    {
    ...
    };

    That ; is too much, remove it. Also:

    int randMon(...)
    {
    ...
    };

    That ; is too much, remove it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem with letters
    By librab103 in forum C Programming
    Replies: 3
    Last Post: 08-08-2003, 01:54 PM
  2. how is this evaluated?
    By jriano in forum C++ Programming
    Replies: 14
    Last Post: 06-18-2003, 09:06 PM
  3. Expression cannot be evaluated
    By *pointer in forum C++ Programming
    Replies: 2
    Last Post: 11-12-2001, 10:17 AM

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