CString and integers
-
Hi all, I'm populating a CString with a set of int's however if the int is less than 10 I want to put a 0 (zero) before it. At present I'm populating the CString by using the format method, so my code looks something like: myString.Format ( "%d, %d, %d", int1, int2, int3) ; I though maybe using the float method I could force a preceding zero but that hasn't worked, my code is below: myString.Format ( "%2.0d, %d, %d", int1, int2, int3) ; does anyone know how to do this? cheers,
-
Hi all, I'm populating a CString with a set of int's however if the int is less than 10 I want to put a 0 (zero) before it. At present I'm populating the CString by using the format method, so my code looks something like: myString.Format ( "%d, %d, %d", int1, int2, int3) ; I though maybe using the float method I could force a preceding zero but that hasn't worked, my code is below: myString.Format ( "%2.0d, %d, %d", int1, int2, int3) ; does anyone know how to do this? cheers,
-
figured it out, just needed to do: myString.Format ( "%02d, %02d, %02d", int1, int2, int3) ; btw does anyone know the term for doing this?
mcsherry wrote:
btw does anyone know the term for doing this?
The term? The 0 is a flag directive, and the 2 is the width.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne