int main(int argc, char** argv) { Heap *openList; int *labyrinth; int *closedList; int *priority; int *previous; int *startDist; /* Initialization of the rng */ srand(time(NULL)); /* Initialisation of the constants and the arrays */ Constants cst = {40,1600,35,857,0.35}; /* Creation of the heap, the labyrinth, and the arrays */ openList = create_Heap(cst); labyrinth = build_Labyrinth (cst); closedList = init_Array(cst); priority = init_Array(cst); previous = init_Array(cst); startDist = init_Array(cst); display_Labyrinth (labyrinth, cst); printf("------------------------------------------------------------\n"); resolve (openList, closedList, startDist, previous, priority, labyrinth, cst); display_Labyrinth (labyrinth, cst); /* Free the allocated memory */ free_Heap (openList); free_Labyrinth (labyrinth); free_Array(closedList); free_Array(priority); free_Array(previous); free_Array(startDist); return 0; }
// // begin main function int main(int argc, char ** argv) { // // break out of main if not enough arguments were supplied // if (argc < 2) { printf("\n\nYou did not include enough parameters. Please try again using './a.out' and 'garage.txt'.\n\n"); return 0; } // // variables // int i; int numberOfCars; car *garage; FILE *txtFile; // // seed random number generator // srand(time(NULL)); // // open files set confirm values // if ( (txtFile = fopen(*(argv+1), "r")) != NULL) { fscanf(txtFile, "%d", &numberOfCars); } else { printf("\n\nThe file did not open. Please try again using './a.out' and 'garage.txt'\n"); return 0; } // // break out of main if file did not open properly and openfiles returns 0 // if (numberOfCars == 0 ) { return 0; } // // fill array from file and return pointer to array // garage = fill_Array(numberOfCars, txtFile); // // close file // fclose(txtFile); // // print formatted array info // printf("\n\nGarage Information:"); print_Garage(numberOfCars, garage); // // sends each car to be 'driven' // for (i = 0; i < numberOfCars; i++) { drive_Car( (garage+i) ); } // // print formatted array info with new mileages // printf("\n\nAfter Driving:"); print_Garage(numberOfCars, garage); // //free allocated memory // free_Array(numberOfCars, garage); // // return 0 to terminate main successfully // return 0; }