C语言基础 00 --- printf

printf(“FILE: %d, LINE: %d, %s/n”, "_FILE_, _LINE_, “这里写上相关信息”);
ANSI C标准中几个标准预定义宏:
_LINE_:在源代码中插入当前源代码行号;
_FILE_:在源文件中插入当前源文件名;
_DATE_:在源文件中插入当前的编译日期;
_TIME_:在源文件中插入当前编译时间;
_STDC_:当要求程序严格遵循ANSI C标准时该标识被赋值为1;
c语言中的__FILE__和__LINE__的作用

#include <errno.h>
#include <string.h>
_FUNC_
_FUNCTION_
printf("%s %s line %d has error: %s\n",_FILE_, _FUNCTION_, _LINE_, strerror(errno));
Error_Handler(_FILE, _LINE_);
打印出错前的行

猜你喜欢

转载自blog.csdn.net/qwxfj/article/details/85638801
今日推荐