Am I using GetTickCount right?



  • Give me a lab assignment. Make a program to distinguish access, measure the speed of the selection of the phrase on the keyboard using the GetTickCount function. I mean, he's recording it in the text file together with the number of milliseconds he's got using the GetTickCount function. After he remembered her, it is proposed to reintroduce the phrase at the right speed of the keyboard. If the phrase and speed of entry coincide with the keyboard, the entry is completed, the entry is not implemented.

    My program always doesn't work out the entrance, though I sat down. Maybe I'm wrong about gettingTickCount. Please advise.

    Programme code itself:

    #include "stdafx.h"
    #include <iostream>
    #include <fstream>
    #include <conio.h>
    #include <string.h>
    #include <string>
    #include <cstdlib>
    #include <windows.h>
    

    using namespace std;

    void zapisvfail()
    {
    char phrase[100]="";
    DWORD startTime=GetTickCount();
    DWORD delta;
    cout<<"Введите фразу"<<endl;
    cin>>phrase;
    delta=GetTickCount()-startTime;
    char result[10];
    _itoa(delta,result,10);
    ofstream outfile("resultingfile.txt");
    outfile<<phrase;
    outfile<<result;
    }

    void checking()
    {
    DWORD startTime=GetTickCount();
    DWORD delta,delta1;
    char checkphrase[100]="";
    char phrase[100]="";
    char result[10];
    ifstream infile("resultingfile.txt");
    infile>>phrase;
    infile>>result;
    delta1=GetTickCount()-startTime;
    char result1[10];
    _itoa(delta1,result1,10);
    cout<<"Введите фразу:"<<endl;
    cin>>checkphrase;
    if((strcmp(phrase,checkphrase)==0) && (result1==result) )
    cout<<"Вход выполнен"<<endl;
    else cout<<"Вход не выполнен"<<endl;
    }

    int _tmain(int argc, _TCHAR* argv[])
    {
    setlocale(LC_ALL,"Russian");
    zapisvfail();
    checking();
    system("pause");
    return 0;
    }



  • Class std and all his functions will be examined later. We'll have to deal with it tomorrow. I'm doing two more programs.

    As long as that's the idea. I get the time then I'll figure it out and round it up to the exact number and then compare it with the time of the introduction of the phrase two times. And I'm putting it on the screen for myself to clearly track and not look into the text file every time.

    In this example, even if he matches a second, he won't come in either.

    #include "stdafx.h"
    #include <iostream>
    #include <fstream>
    #include <conio.h>
    #include <string.h>
    #include <string>
    #include <cstdlib>
    #include <windows.h>
    

    using namespace std;

    void zapisvfail()
    {
    char phrase[100]="";
    DWORD startTime=GetTickCount();
    DWORD delta;
    cout<<"Введите фразу"<<endl;
    delta=GetTickCount()-startTime;
    delta=(delta*10)/1000;
    floor(delta);
    cin>>phrase;
    cout<<delta<<endl;
    ofstream outfile("resultingfile.txt");
    outfile<<phrase;
    outfile<<delta;
    }

    void checking()
    {
    DWORD startTime=GetTickCount();
    DWORD delta,delta1;
    char checkphrase[100]="";
    char phrase[100]="";
    ifstream infile("resultingfile.txt");
    infile>>phrase;
    infile>>delta;
    cout<<"Введите фразу:"<<endl;
    delta1=GetTickCount()-startTime;
    delta1=(delta1*10)/1000;
    floor(delta1);
    cin>>checkphrase;
    cout<<endl;
    cout<<delta1<<endl;
    if((strcmp(phrase,checkphrase)==0) && (delta1==delta) )
    cout<<"Вход выполнен"<<endl;
    else cout<<"Вход не выполнен"<<endl;
    }

    int _tmain(int argc, _TCHAR* argv[])
    {
    setlocale(LC_ALL,"Russian");
    zapisvfail();
    checking();
    system("pause");
    return 0;
    }




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2