Anjaneyulu Anjaneyulu - 1 year ago 77
C Question

Why does the %m format specifier for printf output "Success"?

How is the output of this code is "Success"? When I compiled this code it simply outputs "Success"

#include <stdio.h>

int main(void) {

return 0;

Answer Source

This is a Glibc extension to printf. It outputs the result of strerror(errno) and requires no argument.

From the man page:

   m      (Glibc  extension.)   Print output of strerror(errno).  No argu-
          ment is required.

Since errno starts out at 0 on startup, it prints the message for error code 0, which is Success.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download