if(pc.readable() == 1) // Check if received data { // Case 101 being to clear all arrays pc.scanf("%d", &interrupt); // Receive input if(interrupt == 101) // If 101, clear arrays { pc.printf("\nDeleting arrays...\n"); total_capture_no = 0; free (sched_time_at_start_ptr); free (sched_end_time_ptr); free (sched_count_rate_ptr); free (sched_running_time_ptr); } else if(interrupt < 0) // Error check as you can't have a negative element of the array { pc.printf("\nError! Please choose a number that corresponds to a relevant array element\n"); } else if(interrupt > total_capture_no) // Error check so input reference isn't bigger than the array { pc.printf("\nError! Please choose a number that corresponds to a relevant array element\n"); } else // Only remaining numbers correspond to a specific element in each of the arrays { // Sets all of the values in that array element to 0 sched_time_at_start_ptr[interrupt] = 0; sched_count_rate_ptr[interrupt] = 0; sched_running_time_ptr[interrupt] = 0; sched_end_time_ptr[interrupt] = 0; // Shifts each of the array elements located to the right one place to the left for(int i = interrupt; i < total_capture_no; i++) { sched_time_at_start_ptr[i] = sched_time_at_start_ptr[i+1]; sched_count_rate_ptr[i] = sched_count_rate_ptr[i+1]; sched_running_time_ptr[i] = sched_running_time_ptr[i+1]; sched_end_time_ptr[i] = sched_end_time_ptr[i+1]; } total_capture_no = total_capture_no - 1; // Makes the array one smaller to account for the deleted elements } }