vendredi 19 février 2021

timeval differences pretty printing

ALL,

I'm trying to parse a pcap file and get the difference of the timeval structures beautifully printed to the console.

Something like:

1.2 sec

or

0.4 sec.

To calculate the difference I use:

diff_ms(const timeval tv1, const timeval tv2)
{
    return( ( ( tv1.tv_sec - tv2.tv_sec ) * 1000000) + ( tv1.tv_usec - tv2.tv_usec ) ) /1000;
}

but its printing

12345.

How do I beatify the output?

TIA!

Aucun commentaire:

Enregistrer un commentaire