Printing current file name with extension in C++ -


i writing c++ code , want print current filename extension. yes, it's 1 of asked questions. 1 solution use argv[0]. cool, it's not giving extension. can have extension?

you can print full path name using std::cout << __file__.

if want print file name alone, can do:

std::string file = __file__; size_t index; (index = file.size(); index > 0; index--) {     if (file[index - 1] == '\\' || file[index - 1] == '/')         break; } std::cout << file.substr(index); 

Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -