LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to pad left zeros to a number

hi all
how to divide a number in two halves and pads zeros to the left of a number
0 Kudos
Message 1 of 2
(3,260 Views)

When you format a string from a number, you can pad it with zeroes for example with sprint (string, "%08d", number); this instructions creates a string of (at least) 8 characters padding with zeroes to the left if the number is lower than 99999999; if greater resulting string will be enlarged consequently.

Next you can use strncpy (or StringCopyMax) and strcpy to split the string in two substrings.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 2
(3,248 Views)