Commit e07cf2b0 authored by Kevin Lyda's avatar Kevin Lyda 💬

Based on caution / feedback from SA.

parent 9946b1f4
......@@ -27,6 +27,7 @@ read_number() {
if (!fgets(buf, sizeof buf, stdin)) {
return 0;
}
buf[9] = 0;
return atoi(buf);
}
......@@ -80,9 +81,11 @@ main(int argc, char *argv[]) {
guess = read_number();
delta = end_timer(&timer);
if (guess == 0) {
printf("Got %d correct out of %d.\n", correct, iterations);
printf("Average time to answer was %s\n",
humanize_usec(delta_total / iterations));
if (iterations) {
printf("Got %d correct out of %d.\n", correct, iterations);
printf("Average time to answer was %s\n",
humanize_usec(delta_total / iterations));
}
exit(0);
}
iterations++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment