D
Daragoth
Hi, I'm writing a program using Metrowerks CodeWarrior 4.0 that
determines the best possible combination of a data set by checking
every possible combination. I found there were about 250,000,000
possibilities and decided to insert a cout in the loop that gave the
percentage that had been completed. The program worked, but I soon
realized it would take almost a month of execution time for it to
finish. I figured the cout was slowing the program down so I decided
to make it occur less by mod'ing the program's overall count number
with a large number in an if statement and seeing if it was equal to 0
and putting the cout inside (ie. if (numTries % 10000 == 0) { cout <<
....; }). However, after doing so the program would crash with code
"c0000005" (I later found even using mod 2 would cause it to crash).
I then commented off the if and cout statements, but it still crashed.
When I put the cout statement back by itself it worked fine again. I
then checked with the debugger to see where it was crashing and it
turned out to be a simple addition assignment without overflow. So my
only idea is that the program is running too fast. But due to the
nature of my program, I need it to run as fast as possible. Anyone
know what causes this to happen and how to fix it?
Also, because I would like to be able to pause the program as well as
send various other user-input commands to it without stopping it, is
it possible for a console window to accept keyboard input without
halting execution of the program? I would prefer not to have to alter
the entire program to have it run in a window. Also, is there an
equivalent in CodeWarrior to the clrscr() statement?
Thanks a lot for any help.
Sincerely,
Darien A. Gothia
determines the best possible combination of a data set by checking
every possible combination. I found there were about 250,000,000
possibilities and decided to insert a cout in the loop that gave the
percentage that had been completed. The program worked, but I soon
realized it would take almost a month of execution time for it to
finish. I figured the cout was slowing the program down so I decided
to make it occur less by mod'ing the program's overall count number
with a large number in an if statement and seeing if it was equal to 0
and putting the cout inside (ie. if (numTries % 10000 == 0) { cout <<
....; }). However, after doing so the program would crash with code
"c0000005" (I later found even using mod 2 would cause it to crash).
I then commented off the if and cout statements, but it still crashed.
When I put the cout statement back by itself it worked fine again. I
then checked with the debugger to see where it was crashing and it
turned out to be a simple addition assignment without overflow. So my
only idea is that the program is running too fast. But due to the
nature of my program, I need it to run as fast as possible. Anyone
know what causes this to happen and how to fix it?
Also, because I would like to be able to pause the program as well as
send various other user-input commands to it without stopping it, is
it possible for a console window to accept keyboard input without
halting execution of the program? I would prefer not to have to alter
the entire program to have it run in a window. Also, is there an
equivalent in CodeWarrior to the clrscr() statement?
Thanks a lot for any help.
Sincerely,
Darien A. Gothia