#include #include struct direction { int number; char dir; }; // Return the total number of left steps 'l' int struct_count(int size, struct direction array[size]) { int total_step = 0; for (int i = 0; i < size; i++){ if (array[i].dir == 'l') { total_step = total_step + array[i].number; } } return total_step; } // This is a simple main function which could be used // to test your struct_count function. // It will not be marked. // Only your struct_count function will be marked. #define TEST_ARRAY_SIZE 5 int main(void) { struct direction test_array[TEST_ARRAY_SIZE] = { { .number = 3, .dir = 'l'}, { .number = 5, .dir = 'l'}, { .number = 2, .dir = 'u'}, { .number = 13, .dir = 'd'}, { .number = 30, .dir = 'l'} }; printf("%d\n", struct_count(TEST_ARRAY_SIZE, test_array)); return 0; }