fixed bus error bug when trying to prevent a line from starting with ' '

master
Chiatiah Calson 5 years ago
parent dc2949e478
commit 7fdc19f688

@ -387,14 +387,15 @@ void main_play(int argc_cmd,int *lesson_choice)
{
i=0;
char endl = guess(14, 33);//endl holds the char to end a line in place of usual '\n'
char startl = guess(14, 33); //guess generates a random char
while(i <= chars_to_read)//test on i to get 77 characters. the screen size is exactly 77 characters.
{
linetype[i] = getc(noslac_lessonsp);//getting characters and placing in the linetype array.
if(linetype[0] == ' ')//prevent a the start of a line from ever being a space character
i-=1; //by moving one space back when a space is met
if(linetype[chars_to_read]==' ')//ensuring a line does not with a space character.
linetype[0] = startl; //replace with random char
if(linetype[chars_to_read] == ' ')//ensuring a line does not end with a space character.
linetype[chars_to_read] = '-';//replacing space character at the end of a line with a -
if(i>0)
if(i > 1)
if(linetype[i-1] == ' ' && linetype[i] == ' ')//preventing two consecutive space characters since text read is random.
i -= 2;
//checking and eliminating newlines to prevent brakes.
@ -411,6 +412,7 @@ void main_play(int argc_cmd,int *lesson_choice)
}
i++;
}
linetype[i]='\0';//Adding string terminator and subtracting the number of spaces removed.
if((number_of_lines_count % (block_length)) == 0 && number_of_lines_count != 0)
printf(""LAST_LINE_BLUE"");
@ -452,7 +454,7 @@ void main_play(int argc_cmd,int *lesson_choice)
else if((ch == 127 || ch == 8) && i > 0)//testing for delete of backspace
{
i--;//decremting the number of characters entered when backspaced is pressed.
letter_clear(adapt_to_ver_read());//clearing the backspace printed and making sure it works with many terminal versions
letter_clear(adapt_to_ver_read());
j=wrong_letters;
while(j>u)//counting from u to j, to find if there is a wrong character stored in the error_store array of ints.
{

Binary file not shown.

Binary file not shown.

@ -1,12 +0,0 @@
CHIATIAH CALSON
Sat Apr 13 02:27:57 2019
ERROR(s):0 TIME: 1min:31secs SPEED: ~45.758WPM Accuracy: 100.00%
AVERAGE SPEED: 228.79CPM ~= 45.76WPM
+------------------ Sat Apr 13 02:40:47 2019 -------------------+
|ERROR(s):251 TIME: 29secs SPEED: ~130.345WPM Accuracy: 20.32%
|AVERAGE SPEED: 132.41CPM ~= 26.48WPM
+---------------------------------------------------------------+
Loading…
Cancel
Save