__FILE__宏显示完整路径 [英] __FILE__ macro shows full path
本文介绍了__FILE__宏显示完整路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
标准predefined MACRO在C语言中__FILE__显示完整的文件路径。有什么办法做空路径?我的意思是不是
/full/path/to/file.c
我看
来/ file.c中
或
file.c中
解决方案
尝试
的#include<&string.h中GT;#定义__FILENAME__(strrchr(__ FILE__,'/')strrchr(__ FILE__,'/')+ 1:__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
I see
to/file.c
or
file.c
解决方案
Try
#include <string.h>
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
For Windows use '\\' instead of '/'.
这篇关于__FILE__宏显示完整路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文