printf method

int printf(
  1. String format, [
  2. List args = const []
])

Prints formatted output to stdout, returning the number of characters written.

Supports the full C99 format specifier syntax: %[flags][width][.precision][length]specifier

Flags: - (left-align), + (force sign), (space sign), 0 (zero-pad), # (alternate form).

Width / Precision: integer literal or * (read from next argument).

Specifiers: d, i, u, o, x, X, f, F, e, E, g, G, s, c, p, n, %.

Example:

stdc.printf("%+010.4f\n", [3.14]);  // "+003.1400"
stdc.printf("%-8s|\n", ["hi"]);     // "hi      |"
stdc.printf("%#010x\n", [255]);     // "0x000000ff"

Implementation

int printf(String format, [List<dynamic> args = const []]) {
  final ap = va_start(args);
  final result = vprintf(format, ap);
  va_end(ap);
  return result;
}