The output for this code printed out ‘Success’.
printf("%m\n");
The format specifier is used during input and output. It is a way to tell the compiler what type of data is in a variable during taking input using scanf() or printing using printf().
An unsigned Integer means the variable can hold only a positive value. This format specifier is used within the printf() function for printing the unsigned integer variables. Syntax: printf(“%u”, variable_name);
m
conversion specifier is not C but is a GNU extension to printf
:
From GNU documentation:
http://www.gnu.org/software/libc/manual/html_node/Other-Output-Conversions.html
The ‘%m’ conversion prints the string corresponding to the error code in errno. See Error Messages. Thus:
fprintf (stderr, "can't open `%s': %m\n", filename);
is equivalent to:
fprintf (stderr, "can't open `%s': %s\n", filename, strerror (errno));
The ‘%m’ conversion is a GNU C Library extension.
So:
printf("%m\n", d);
is equivalent to
printf("%s\n", strerror (errno), d);
which is equivalent to
printf("%s\n", strerror (errno));
Note that %m
does not require an argument. Here printf("%m\n", d)
and printf("%s\n", strerror (errno), d)
have more arguments than required: with printf
if there are extra trailing arguments, they are just evaluated and ignored.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With