Quote:
Originally Posted by Stefan
EDIT: One question
what is the difference between:
Code:
char achar[80];
achar[80]=0;
and:
Code:
char achar[80];
for (int i=0; i < 80; i++)
achar[i]=0; // or achar[i]='\0';
?
|
First off, the first one
char achar[80];
achar[80] = 0;
will produce an access violation error.
You declare an array of characters, 80 characters wide.
Then you tell it to put the
81th character to zero. I mean, Stefan, get more sleep, I *mean it*
The second one
char achar[80];
for (int i = 0; i < 80; i++)
achar[i] = 0;
will take each element of this array successively, starting from element #0 (first element) up to element #79 (80th element, i.e. the size of your array), and reset it to zero. ALL your character array will be reset to zero.
What are you up to ??
*edit* OMG, I've just taken a deeper look in the code you posted, it's terrible!! 8o 8o 8o Do you know how many times you are writing beyond the limit of your arrays ??? And you wonder why your bot crashes randomly ?? omfg, if the hwole RealBot is written this way, then it's driven by MAGIC ! Fix that or do something but get this out of my sight quick !!
*edit 2* OK, since I'm a good boy (well, I think...) I'm gonna give you a hint dude.
To clear out an array without wasting time doing a test for each character, use memset().
char achar[80];
memset (achar, 0, sizeof (achar));
And your whole array is reset to zero, completely, it takes a millionth second.