[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppBuilderGetExtension
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppBuilderGetExtension
(C++ Builder) Get the extension of a filename
Use String's member function SubString:String getExtension(const String& fileName) { const int index = fileName.Length()-2; const int count = 3; return fileName.SubString(index,count); } void __fastcall TForm1::Button1Click(TObject *Sender) { const String fileName = "autoexec.bat"; assert( getExtension(fileName) == "bat"); }
- include <assert> //For assert
- include <System.hpp> //For String
Other code snippets
Code links
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
