内容: 记录printf格式化串选项中的一个不常用,但是挺有用的选项:%m
作用:打印当前errno
的原因
实例:
#include <stdio.h>
#include <string.h>
#include <errno.h>
int main()
{
printf("%m\n");
printf("strerrno = %s\n", strerror(errno));
//修改errno再查看%m会发生什么?
printf("\nnow modify the value of errno,and printf the %m again :\n\n");
errno = 1;
printf("%m\n");
printf("strerrno = %s\n", strerror(errno));
return 0;
}
结果:
luzejia@ubuntu:~$ ./a.out
Success
strerrno = Success
now modify the value of errno,and printf the Success again :
Operation not permitted
strerrno = Operation not permitted