Errors, bugs, questions - page 2494

 
Сергей Таболин:
Roman, before you lecture, learn for yourself.

Since you are turning to the community for help, no one is going to teach you.
I wanted to help you, but it is really hard to see where you declared and where you appropriated.
You might at least have separated arrays by blocks, for readability )) but never mind, I've figured it out.
Try to go through the loops in the debugger, you'll see where the problem is.

 

@Sergey Tabolin

What values canbalance_arr_size take?

How isbalance_arr defined?

 
Francuz:

@Sergey Tabolin

What values canbalance_arr_size take?

How isbalance_arr defined?

There's no problem with that. They are used before this code section and don't cause any questions.

I found the error in filling the array.

   // коррекция
   int      correcton_index[3];
   ArrayInitialize(correcton_index,NULL);
            correcton_index[0]   = 1;
            correcton_index[1]   = (int)MathRound(balance_arr_size / 2);
            correcton_index[2]   = balance_arr_size;
   int      correcton_index3[5];
   ArrayInitialize(correcton_index3,NULL);
            correcton_index3[0]  =  1;
            correcton_index3[1]  = (int)MathRound(correcton_index[1] / 2);
            correcton_index3[2]  = correcton_index[1];
            correcton_index3[3]  = (int)MathRound((correcton_index[2] - correcton_index[1]) / 2) + correcton_index[1];
            correcton_index3[4]  = balance_arr_size;
   int      correcton_index7[9];
   ArrayInitialize(correcton_index7,NULL);
            correcton_index7[0]  = 1;
            correcton_index7[1]  = (int)MathRound(correcton_index3[1] / 2);
            correcton_index7[2]  = correcton_index3[1];
            correcton_index7[3]  = (int)MathRound((correcton_index3[2] - correcton_index3[1]) / 2) + correcton_index3[1];
            correcton_index7[4]  = correcton_index3[2];
            correcton_index7[5]  = (int)MathRound((correcton_index3[3] - correcton_index3[2]) / 2) + correcton_index3[2];
            correcton_index7[6]  = correcton_index3[3];
            correcton_index7[7]  = (int)MathRound((balance_arr_size - correcton_index3[3]) / 2) + correcton_index3[3];
            correcton_index7[8]  = balance_arr_size;

Without it, the values turned out to be incorrect but the most interesting thing was that some of the values were negative. Correspondingly, when trying to address an array item with index [-6], the programmer got an overrun of the array.

I should have unprinted everything from the beginning (I wanted to) and checked the values )))

 
Сергей Таболин:

There is no problem with this. They are used before this part of the code and do not cause any problems.

I found the error in filling the array.

Without it the values turned out to be incorrect but the most interesting thing is that some values turned out to be negative. Correspondingly, when trying to address an array item with index [-6], the programmer got an overrun of the array.

I should have unprinted everything at first (I wanted to) and checked the values )))

I was speaking about the source. And the source of the problem is just in these two variables(balance_arr_size andbalance_arr) the rest of the code depends on them.

 
Francuz:

I was talking about the source. And the source of the problem is just these two variables(balance_arr_size andbalance_arr) the rest of the code depends on them.

They have absolutely nothing to do with it. The error was in the index calculation.

 
Сергей Таболин:

They had absolutely nothing to do with it. The error was in the index calculation.

Then there are two possibilities, either you gave corrected code in the first post, or you don't see that all indexes are defined bybalance_arr_size variable?

 
Francuz:

Then there are two possibilities, either you gave corrected code in the first post, or you don't see that all indexes are defined via balance_arr_size variable ?

The corrected code is three posts above. Look through it carefully and hopefully you will understand that balance_arr_size cannot affect the error in any way. Once again, let's spell it out - the error wasin the parsha of the I n d e c s o!!!

Or are you saying that I have found the WRONG mistake ? Assign any value to the variable (and in this context, the static variable) balance_arr_size and calculate on a calculator what you get in the first version and what you get in the second.

By the way, you are already the second one who is persistently rubbing his point. And then there will be statements: "Oh, I didn't see, oh, I didn't look through...".

 
Сергей Таболин:

The corrected code is three posts above. Take a closer look and hopefully you will understand that balance_arr_size cannot affect the error in any way. Once again, spell it out - the error was in the parsha of the I n d e c o n s!!!

Or are you saying that I have found the WRONG mistake ? Assign any value to the variable (and in this context, the static variable) balance_arr_size and calculate on a calculator what you get in the first version and what you get in the second.

By the way, you are already the second one who is persistently rubbing his point. And then there will be statements: "Oh, I didn't see, oh, I didn't look through...".

With such a way of speaking, next time you will be right and you will have to find it yourself.
In your code, you haven't shown how many elementsbalance_arr containswhendeclaring it.
You were correctly told to check how many elementsbalance_arr array is declared.
We are not telepaths to guess what array it is and how it is declared. That's why they suggest possible trouble spots.
If everything is OK there, the problem is really just in the indexing calculation.
And please change your tone of voice.
Honestly, next time you speak like that, hardly anyone will even look through your code.
Good luck with that.

 
Roman:

With this style of communication, the next time you're right, you find it yourself.
In your code, you have not shown how many elements balance_arr contains in the declaration.
You were correctly told to check how many elements balance_arr array is declared.
We are not telepaths to guess what array it is and how it is declared. That's why they suggest possible trouble spots.
If everything is OK there, the problem is really just in the indexing calculation.
And please change your tone of voice.
Honestly, the next time you use that tone of voice, I doubt anyone will even look at your code.
Good luck with that.

Funny ))))

Does that mean it's my fault that some individuals need to repeat the same thing several times? And spell it out? Especially after saying I found the mistake myself? Fucking hell! If you do not understand Russian, you better not even try to "help".

 
Сергей Таболин:

Funny ))))

Does that mean it's my fault that some individuals need to repeat the same thing several times? And spell it out? Especially after saying I found the mistake myself? Fucking hell! If you don't understand Russian, you'd better not try to "help".

You still don't know what I'm talking about. I wasn't talking about an error in your code. I was speaking about the error of posting a piece of code where two key terms are undefined. The source of the problem is that you didn't define the two key members and you're asking for help.

Reason: