Obscure errors, troubleshooting, anyone?

This is a discussion on Obscure errors, troubleshooting, anyone? within the Game Programming forums, part of the General Programming Boards category; Okay. look at my program and see if you can figure out these problems... 1- pointer CN[4] (not 3,2,or1) is ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    4

    Question Obscure errors, troubleshooting, anyone?

    Okay. look at my program and see if you can figure out these problems...
    1- pointer CN[4] (not 3,2,or1) is changed to the value of WE when WFK calls Event()
    2- int CEXPGoal[4] is assigned a value of 127 but it is immediately changed to 10 even before you call status()
    3- int CMHP[4] is changed from 30 to 1 when sleeping at the inn...

    I expect to solve these problems in the next couple of weeks, but any help would be appreciated. also any suggestions/comments you have would be welcome and, indeed, valued.
    As of right now, i'm guessing that there is some kind of memory overlay in the variable declaration section (not definition)...
    i've just recently figured out how to do pointers/arrays so perhaps i've made some mistake...


    Aaron/Golbez/Kainazzo/Valvalis/Ruben/Milon/Zemus/Zeromus
    oh, btw i use Borland version whatever...
    Attached Files Attached Files

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>pointer CN[4] (not 3,2,or1)
    Thats because you access array element via 0-n, not 1-n. So in your case its, CN[0], CN[1], CN[2], CN[3] only. CN[4] is not in this variables memory scope, you are overwriting someone elses data, and they will happily return the favour.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    4

    Unhappy Still having problems...

    well i changed all variables to correct the 0-4 problem.
    However, i only got more of the same errors. now it changes almost every variable; most change to 10 or 1 but one changes to 420463 or something...
    i tested it by printing the values to the screen, even right after i assigned the values, and they were already messed up.
    i dont know what is happening, but i wish it would stop.
    I will include the updated version of Game.cpp...
    thanks in advance for any help i get...
    Aaron
    Attached Files Attached Files

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>well i changed all variables to correct the 0-4 problem
    Not quite, you didn't

    Look:
    Code:
    int CCON[3];
    ...
    CCON[0] = 6;
    ...
    CCON[1] = 10;
    ...
    CCON[2] = 6;
    ...
    CCON[3] =5;
    You allocated CCON as an array of ints, size 3. Then you filled CCON[0] - CCON[3] with numbers. But that's 4 elements, not 3. So the last one went beyond the end of the array.

    You should declare your array with the total number of elements required:
    >>int CCON[4];
    and then fill the elements, using the notation 0 to N-1, in this case CCON[0] - CCON[3].

    This might not be all of your problems, but you need to get this right first.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #5
    Visionary Philosopher Sayeh's Avatar
    Join Date
    Aug 2002
    Posts
    212
    I expect to solve these problems in the next couple of weeks,
    Based on Hammer's corrections and your response, I think it fair to warn you that it is potentially unlikely you will, by yourself, ever solve these problems. You basic problem seems to stem from the fact that you don't even grasp the syntax of the language. Therefore, I would recommend you learn the syntax and language grammar necessary before delving into the deeper mysteries of writing logic.
    It is not the spoon that bends, it is you who bends around the spoon.

  6. #6
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704

    That last post reminds me of a good quot.

    "If you programmed code using the full extent of your cunning skills, ingenuity, and to the best of your ability, then by definition, you are not smart enough to debug it."
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ten Errors
    By AverageSoftware in forum Contests Board
    Replies: 0
    Last Post: 07-20-2007, 10:50 AM
  2. Winsock compilation errors
    By jmd15 in forum Networking/Device Communication
    Replies: 2
    Last Post: 08-03-2005, 08:00 AM
  3. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM
  4. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 05:51 PM

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