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