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;
}
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;
}
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
.