What does the %*s format specifier mean?

It’s used to specify, in a dynamic way, what the width of the field is:

  • The width is not specified in the format string, but as an additional
    integer value argument preceding the
    argument that has to be formatted.

so “indent” specifies how much space to allocate for the string that follows it in the parameter list.

So,

printf("%*s", 5, "");

is the same as

printf("%5s", "");

It’s a nice way to put some spaces in your file, avoiding a loop.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)