The c_str() method of the std::string class returns a pointer to const char so that you can't modify the result. Unfortunately, there's no good solution, and you can thank the author of the library who didn't write const-correct code. Now, if you know that the function will not modify the string, you can use const_cast to allow the conversion:
char *FileExt = const_cast<char*> ( path.c_str() );
If you're not sure whether the function will modify the string or not, you have no choice but to create a C-style string copy:
char *FileExt = new char[path.size() + 1];
std::strcpy ( FileExt, path.c_str() );
strcpy is declared in <cstring>.
>oh and by the way ive tried casting it using static_cast
static_cast doesn't remove qualifiers, which is a very good thing because you have to actively choose const_cast, and therefore can't do it by accident.