How to get file extension from string in C++

前端 未结 25 2426
迷失自我
迷失自我 2020-11-30 22:35

Given a string \"filename.conf\", how to I verify the extension part?

I need a cross platform solution.

25条回答
  •  独厮守ぢ
    2020-11-30 23:34

    A NET/CLI version using System::String

       System::String^ GetFileExtension(System::String^ FileName)
       {
           int Ext=FileName->LastIndexOf('.');
           if( Ext != -1 )
               return FileName->Substring(Ext+1);
           return "";
       }
    

提交回复
热议问题