__FILE__ 宏显示完整路径 [英] __FILE__ macro shows full path
本文介绍了__FILE__ 宏显示完整路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
C 中可用的标准预定义宏 __FILE__
显示文件的完整路径.有什么办法可以缩短路径吗?我的意思是而不是
The standard predefined macro __FILE__
available in C shows the full path to the file. Is there any way to short the path? I mean instead of
/full/path/to/file.c
我明白了
to/file.c
或
file.c
推荐答案
尝试
#include <string.h>
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
对于 Windows,使用 '\' 而不是 '/'.
For Windows use '\' instead of '/'.
这篇关于__FILE__ 宏显示完整路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文