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
__FILE__
/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 '/'.
2.1m questions
2.1m answers
60 comments
57.0k users