I'm trying to output a period (".") every second pending a timeout. I need a way to check that a second has passed, and I'm hoping to do it really succinctly.
My foolish attempt:
if (std::chrono::system_clock::now() % std::chrono::seconds(1))
std::cout << ".";
My head went to the modulus operator since I would typically use that if I were stepping through a loop using an integer to check if it were a multiple of something (or even or odd), but perhaps I've gone the wrong direction.
Aucun commentaire:
Enregistrer un commentaire