mercredi 28 mars 2018

How to output time in milliseconds in c++?

#include <iostream>
#include <chrono>
#include <time.h>
#include <stdio.h>
using namespace std;
using namesapce chrono;

int main() {
int f;
time_t start, end;
time (&start);
cin >> f;
time (&end);
double dif = difftime (end, start);
printf ("Elapsed time is %.2lf seconds.", dif );
}

Hello everyone, I am currently working on a c++ assignment and I am essentially required to have the user input something within 10 seconds. I managed to find out how to count the time by the second but I need it to be by milliseconds because I have to find out how many milliseconds above 10 seconds was elapsed. I am not that experienced with C++ and would very much appreciate any suggestions that may help steer me in the right way. Thanks a lot

Aucun commentaire:

Enregistrer un commentaire