All pastes #13389 Raw Edit

Untitled

public text v1 · immutable
#13389 ·published 2005-06-04 21:10 UTC
rendered paste body
#include <iostream>
#include <time.h>
#include <string.h>
#include <windows.h>

using namespace std;

int main(int argc, char * argv[]) {
	int BPM = 0;
	int counter = 0;
	int start = time(NULL);

    char buffer[1] = ""; 
    DWORD w; 
    HANDLE keyboard = GetStdHandle(STD_INPUT_HANDLE); 
    INPUT_RECORD input[1];

	bool running = true;
	while (running) {
		ReadConsoleInput(keyboard, input, 1, &w);

		if (input[0].EventType == KEY_EVENT && input[0].Event.KeyEvent.bKeyDown) {
			buffer[0] = input[0].Event.KeyEvent.uChar.AsciiChar;

			if (buffer[0] == 13) {
				counter++;
			}
		}

		BPM = counter / (start - time(NULL));

		cout << BPM;
	}

	return 0;
}