Anjaneyulu Anjaneyulu - 7 months ago 43
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;


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.