//------------------------------------------------------- // Example of how to log information in PbO // // Written by: Quinn Hsu // Determines the smallest integer in an array of integers // Purposefully inserted bug to demonstrate how ##LOG // can be used in debugging //------------------------------------------------------- #include int min_element(const int *array, int length) { int i, smallest; smallest = array[0]; ##LOG(int inside_min_element_initial_smallest = smallest) for(i=1; i smallest) { // mistake smallest = array[i]; ##LOG(int inside_min_element_new_smallest = smallest) } } return smallest; } int main(int argc, char** argv) { int array[] = {5,16,7,39,5,2,40,5}; ##LOG(string outside_min_element = "entering min_element()") int smallest = min_element(array, 8); ##LOG(string outside_min_element = "exiting min_element()") // smallest should be 2 printf("The smallest element in the array was %d\n", smallest); }