1

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

#include <stdio.h>

int main(void) {

    printf("%m");
    return 0;
}
dbush
  • 205,898
  • 23
  • 218
  • 273
Anjaneyulu
  • 434
  • 5
  • 21

1 Answers1

6

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.

dbush
  • 205,898
  • 23
  • 218
  • 273