From Professor Harry Porter’s Fall 2015 CS201 course: External link
Implement a game that tests the player’s typing speed in the C programming language. The game randomly chooses words from an array of null-terminated strings containing "The, "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog". Each word must appear exactly once during a game round. If the user incorrectly types a word, the program should prompt the user to retype the incorrect word.
At the end of each game round, the program should display the total amount of time it took the user to complete the round and how many mistakes they made.
Random permutations of words should be generated via calls to srand()
and rand()
.
Each permutation of the words must be possible.
Ensure that your random permutation is generated using a minimal number of rand()
calls.
Timing should begin when the random permutation is first given to the user.
Timing should end when the user correctly inputs the permutation correctly.
At PSU, this assignment is to be implemented and run on the department’s linux system. So there are some additional requirements.
Consult the linux man pages for more information on rand()
, /srand()
, gettimeofday()
, timersub()
, printf()/scanf()
, strlen()
, strncmp()
etc.
Seed srand()
using the usec
field from a call to gettimeofday()
Use timer macro timersub()
for handling operations on struct timevals
(/usr/include/sys/time.h)
.