I am using c++ and would like to know the easiest way to turn decimals in to the form hours:minutes:seconds.

You can assume the integer is in the form of hours (e.g. 242.4 = 242 hours 24 seconds etc)

Also, I would like it so that seconds is to one decimal place, and that if a field is blank it will show up like this 00:00:00.0

Thanks heaps :mrgreen:

Ok i worked out the setfill(n) function, so i just need the other part

modf() will help you split a floating point number into its integer and fractional parts. see man pages for more details8

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.