The std::string manages it's own memory internally which is why, when it returns a pointer to that memory directly as it does with the c_str() function it makes sure it's constant so that your compiler will warn you if you try to do something incredibly silly like attempt to change it.

Using const_cast in that way literally casts away such safety and is only an arguably acceptable practice if you are absolutely sure that memory will not be modified. If you can't guarantee this then you must copy the string and use the copy; it's certainly a lot safer to do this in any event.

Here's a variation of 7stud's safe approach:.
Code:
#include <iostream>
#include <string>
#include <vector>

namespace 
{
  char* GetNonConstStr(const std::string& s)
  {
  //return non-constant copy of s.c_str()
  static std::vector<char> var;
  var.assign(s.begin(),s.end());
  var.push_back('\0');
  return &var[0];
  }
  
  void someCFunction(char* str)
  {
    std::cout<<str<<std::endl;
  }
}

int main()
{
std::string s("hello world");
std::string t("hello multiverse");

someCFunction(GetNonConstStr(s));
someCFunction(GetNonConstStr(t));
}