dynamic format specifier possible?

forkit forkit at gmail.com
Sun Jan 23 21:59:25 UTC 2022


I would like to calculate the width of the format specifier 
dynamically, at runtime.

e.g int WIDTH = something.length;

then my format specifier would be: %WIDTHs instead of %9s

// ---

module test;

import std;

void main()
{
     int val = 999000;
     writefln("[%9s]", val); // [   999000]
}

// ---


More information about the Digitalmars-d-learn mailing list