I have been trying to make a wpm counter and, long story short, am running into an issue:
After using the high resolution clock, I need to divide it by 12, but I can't convert std::chrono
to int
. Here is my code:
#include <iostream>
#include <chrono>
#include <Windows.h>
#include <synchapi.h>
using namespace std;
using namespace std::chrono;
int main()
{
typedef std::chrono::high_resolution_clock Time;
typedef std::chrono::seconds s;
string text;
string ctext = "One two three four five six seven eight nine ten eleven twelve";
cout << "Type: "<< ctext << " in" << "\n" << "5" << endl;
Sleep(1000);
cout << "4" << endl;
Sleep(1000);
cout << "3" << endl;
Sleep(1000);
cout << "2" << endl;
Sleep(1000);
cout << "1" << endl;
Sleep(1000);
cout << "GO" << endl;
auto start = Time::now();
cin >> text;
auto stop = Time::now();
float wpm = stop - start / 12;
if (ctext == text)
{
cout << "Correct! WPM: " << wpm;
}
else
{
cout << "You had some errors. Your WPM: " << wpm;
}
}
Are there any alternative methods I could also use to using std::chrono for this?