Getting file name and path in C/C++

The standard predefined MACRO __FILE__ available in C shows the full path to the file.

#include <stdio.h>

int main()
{
    char *ab = __FILE__;
        
    // directly 
    printf("%s",__FILE__);
    
    // or from variables
    printf("\n%s",ab);
    
    
    getchar();
    return 0;
}