C++ calculating time intervals

后端 未结 5 1415
情歌与酒
情歌与酒 2021-01-22 08:05

I want to calculate time intervals (in 1/10th of 1 second) between some events happening in my program. Thus I use clock function for these needs like follows:

5条回答
  •  忘掉有多难
    2021-01-22 08:20

    Maybe you have to typecast it to double.

    cout << (double)(diff / CLOCKS_PER_SEC) << "\n";
    

    Integers get rounded, probably to 0 in your case.

提交回复
热议问题