#include "utils.h" #include #include #include void print_line(void) { printf("--------------------------------------------------\n"); } void wait_enter(const char *msg) { if (msg) printf("%s", msg); int c; while ((c = getchar()) != '\n' && c != EOF) ; } char ask_yes_no(const char *msg) { char c = 'n'; printf("%s", msg); if (scanf(" %c", &c) != 1) c = 'n'; int flush; while ((flush = getchar()) != '\n' && flush != EOF) ; return c; } void now_str(char *buf, size_t size) { time_t t = time(NULL); strftime(buf, size, "%Y-%m-%d %H:%M:%S", localtime(&t)); } size_t rand_index(size_t max) { return max ? (size_t)(rand() % max) : 0; }