Op Mon, 14 May 2007 14:12:07 +0200 schreef Michael Frederick
<>:
> I'm having a bit of dippy here, can anyone help?
>
> How do I extract x digits from an Integer.
>
> For example int iTime = 101237
> I need to make it into a string in the format "10:12:37" therefore if
> I could get "10" "12" and "37" all would be well. I initially thought
> I could do it with a mask (binary and) but to no avail.
Decimals are not binary, so you cannot binary mask them.
#include <stdio.h>
char str[9];
sprintf (str, "%06d", iTime);
/* src 012345..\0 */
/* dst 01:23:45\0 */
str[7] = str[5];
str[6] = str[4];
str[4] = str[3];
str[3] = str[2];
str[5] = str[2] = ':';
Voila!
> Can someone put me out of my misery?
That can be arranged as well.
--
Gemaakt met Opera's revolutionaire e-mailprogramma:
http://www.opera.com/mail/