Thanks Salem.
I using the constant got rid of the seg fault.
But the problem is now the board is not being updated on each tick count of the timer.
Il post the whole game function:
Code:
int playGame ( char rctrk[], const char *tur, const char *hre, const int SIZE ) {
// these are used to check if the T or H go beyond array
// boundarys
int turtleLimit = 0,
hareLimit = 0;
for ( int i = 0; i <= 30; ) {
for ( int j = 1; j <= 3; j++ ) {
std::cout << "\n";
}
int eventChoice = ( 1 + rand() % 8 );
std::cout << std::setw ( 52 ) << announceStart() << "\n\n";
std::cout << "\nSeconds Lapsed: " << i << "\n\n";
printRaceCourse ( rctrk, SIZE );
switch ( eventChoice ) {
case 1:
std::cout << turtFastPlod ( rctrk, tur, turtleLimit, SIZE );
break;
case 2:
std::cout << turtSlip ( rctrk, tur, turtleLimit, SIZE );
break;
case 3:
std::cout << turtSlowPlod ( rctrk, tur, turtleLimit, SIZE );
break;
case 4:
std::cout << hareSleep ( rctrk, hre );
break;
case 5:
std::cout << hareBigHop ( rctrk, hre, hareLimit, SIZE );
break;
case 6:
std::cout << hareBigSlip ( rctrk, hre, hareLimit, SIZE );
break;
case 7:
std::cout << hareSmallHop ( rctrk, hre, hareLimit, SIZE );
break;
case 8:
std::cout << hareSmallSlip ( rctrk, hre, hareLimit, SIZE );
break;
default:
std::cout << "\n\nERROR!\n\n";
break;
}
Sleep(1000);
clear_screen();
i++;
}
return 0;
}
And the change to the movement functions ( all right look the same as this bar a different
string being returned for the movement text
Code:
std::string turtFastPlod ( char rctrk[], const char *tur, int &rtl, const int SIZE ) {
std::string str = "\n\nTURTLE: FAST PLOD\n";
rtl += 3;
if (( rtl < SIZE ) || ( rtl > SIZE )) {
return "";
}
rctrk[ rtl ] = *tur;
return str;
}
It has got somthing to do with the value I am giving rctrk[ ] but I am not sure what I am doing
wrong. Did I make the mistake removing the zero the rtl?