It's a bug. Hasn't worked since introduced in build 600 (2014). Simple workaround.
PrintFormat(StringFormat("<%%0%dd>",5),12); // <00012>
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
It's a very basic content, but I have doubts.
I searched in the forum for the time being, but I can't find a similar topic as well.
The "PrintFormat(printf)" document says
----
https://docs.mql4.com/common/printformat
width:
If an asterisk (*) is specified as width, value of int type must be indicated in the corresponding place of the list of passed parameters. It will be used for specifying width of the output value.
----
But I tried this code
printf("%0*d",4,1);
(outputs) :=> 0*d
printf("%.*f",3,0.1);
(outputs) :=> .*f
Not work right.
printf("%04d",1);
(outputs) :=> 0001
printf("%.3f",0.1);
(outputs) :=> 0.100
Yes. work right.
Some other langulage, perl, python, ruby etc.. (php is not implimented)
For exsample,
perl -e "printf('%0*d, %.*f',4,1,3,0.1)"
(outputs) :=> 0001, 0.100
Yes, work right.
Please let me know if this is the wrong document(Not implement), or a bug, or my misuse.
I use MT4 Build 1355 16 Mar 2022 (Download at XMTrading).
Thanks.