AI Features

Format Specifiers: Width, Separator, Precision and Flags

This lesson explains four more parts of the format specifier: width, separator, precision and flags.

We'll cover the following...

Width

This part determines the width in characters that the argument is displayed in. If the width is specified as the character *, then the actual width value is read from the next argument (that argument must be an int). If width is a negative value, then the - flag is assumed.

D
import std.stdio;
void main() {
int value = 100;
writefln("In a field of 10 characters:%10s", value);
writefln("In a field of 5 characters :%5s", value);
}

Separator

The comma character is used to separate digits of a number in groups. The default number of digits in a group is 3, but it can be ...