参考自《Linux程序设计》第二版 P137
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <syslog.h>
int main(void){
FILE *pfile;
pfile = fopen("/home/kkk", "r");
if(!pfile){
syslog(LOG_ERR, "Error: %m");
}
exit(0);
}
$tail -1 /var/log/messages
Feb 18 23:01:38 lujinhong a.out: Error: No such file or directory