This is my first real attempt at c++, and also my first post on stack overflow (Hello!). The trouble I'm having is that my code used to run fine, but then started having an error where it would just terminate after a certain point without completing the task. I've done some debugging and isolated the problem to two variables in one if statement. If I replace them in the if statement with 1's, the code starts working again, although not as intended. I cannot for the life of me figure out why it is acting this way. Could it be the compiler? I'm using CppDroid on an android device to write and test it.
if (poolSize > 46) poolSize = 46;
bool inclSpace = 0;
if (length > 5) inclSpace = 1
int x = 0;
int rNum;
int spaceDist = 0;
while (1)
{
if (x >= length)
break;
rNum = rand();
if (inclSpace && (length - 1) != x && cout << "past error check 1\n" &&
/* troubles start here */ (rNum & 0x3C00) < (spaceDist * 0x0400) && /* and end here */
cout << "past error check 2\n")
{
spaceDist = 0;
a[x] = ' ';
}
I would post the whole thing but it's over 270 lines long and idk how relevant it would be to my problem because I think I isolated it pretty well. The code always prints the first error check and never the second unless I remove the variables. Let me know what you think!
Thank you for your time!
Aucun commentaire:
Enregistrer un commentaire