#include #include #include "coordinate.h" #include "input.h" #define LENGTH 80 static Coord _input_coord() { char line[LENGTH]; int done = 0; while (!done) { fgets(line, LENGTH, stdin); if (strnlen(line, LENGTH) == 3 && line[2] == '\n') line[2] = 0; if (!coord_is_valid(line)) printf("Invalid coordinate. Write something like \"e2\": "); else done = 1; } return coord_init(line); } Coord input_orig_coord() { printf("Orig coordinate: "); return _input_coord(); } Coord input_dest_coord() { printf("Dest coordinate: "); return _input_coord(); }