Programming typing speed test c++?
Im stuck on my program that i need to do. Im asked to type in this sentence and then i need to have it say how many seconds did it take to type in the sentence. If you know how to do this can you help point me in the right direction. I dont need to worry about the errors in the sentence just the speed.
well thats sort of what i want i tried to compile that it didnt work. I all ready started a program but im having problems compiling it im getting a error. 'operator-'not implemented in type 'Time' for arguments of the same type in function main
- siamese_scytheLv 71 decade agoFavorite Answer
The answers above ought to do the trick. Some additional info: For a *real* speed test, you would probably want to compute the edit distance between the actual string and the string the user typed (or some similar measure), and use that along with time to compute the score. Algorithms for edit distance can be found through normal internet searches for which the top hit will most likely be wikipedia.
- oopsLv 61 decade ago
using namespace std;
clock_t start, end;
start = clock();
cin >> sentence;
end = clock();
double seconds = (double)(end - start) / CLOCKS_PER_SEC;
cout << "Typing the sentence took " << seconds << " seconds.";
Edit: Are you referencing my code in your additional details? Because if you tried this code, you could not have got any errors, as this is error free C++. If you got errors with this code, either you copied it wrong, or there's something wrong with your compiler.
- PoohBearPenguinLv 71 decade ago
1. take the time
2. ask for the user to type the sentence
3. take the time again
4. subtract 1 from 3.
5. DING! print the result
- pattieLv 44 years ago
Would like to find out more about this as well