I\'ve written a c++ function to get the current time in HH:MM:SS format. How can I add milliseconds or nanoseconds, so I can have a format like HH:MM:SS:M
HH:MM:SS
HH:MM:SS:M
Instead of using time() (seconds since the epoch), try gettimeofday(). Gives you a structure that includes a microseconds field.
time()
gettimeofday()