#include <sys/types.h>
#include <sys/time.h>
+#include <unistd.h>
#include <dirent.h>
#include <errno.h>
#include <string.h>
category_print (category, file);
+ fsync (fileno (file));
fclose (file);
err = rename (lock_filename, filename);
while (1) {
if (category->time_limit > 0.0) {
- readline ("The next one is timed. Press enter when ready:");
+ response = readline ("The next one is timed. Press enter when ready:");
+ free (response);
}
printf ("%s\n", item->challenge);
return;
}
- if (response[0] == '/')
+ if (response[0] == '/') {
mnemon_handle_command (mnemon, response + 1);
- else
+ free (response);
+ } else {
break;
+ }
}
mnemon_handle_response (mnemon, bin, item_index,
(end.tv_sec + end.tv_usec / 1e6) -
(start.tv_sec + start.tv_usec / 1e6),
category->time_limit);
+ free (response);
} while (mnemon->to_introduce ||
mnemon->unlearned ||
mnemon->to_master > 0);
-
- printf ("Great job.\n");
}
int
main (int argc, char *argv[])
{
mnemon_t mnemon;
+ char *response;
srand (time (NULL));
mnemon_fini (&mnemon);
+ mnemon_init (&mnemon);
+ mnemon_load (&mnemon);
+
+ printf ("Great job.\nHere are your current results:\n");
+ mnemon_print_histogram (&mnemon, NULL, 0);
+ response = readline ("Press enter to quit.\n");
+ free (response);
+
+ mnemon_fini (&mnemon);
+
return 0;
}