hi all,
i want to print time in HH:MM:SS:MS<millisec> format... how to do??
Thanks in advance....
./senthil
hi all,
i want to print time in HH:MM:SS:MS<millisec> format... how to do??
Thanks in advance....
./senthil
Last edited by msenthil; 10-24-2007 at 01:02 AM.
Where are you reading time from, and in what format?
Apart from milliseconds, I would use time.h and strftime().
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
using date command im reading time.
Well then look at the date man page. Something like this
gives you HH:MM:SS. I don't see an option for milliseconds.Code:date '+%H:%M:%S'
Why are you using the date command, anyway? It's not very portable, and depending on how you are executing it, probably slow.
Consider using some functions from time.h. There are also unportable Linux functions that return milliseconds, but I can't recall their names at the moment.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.