This forum has been archived. Please start a new discussion on GitHub.

Using Char* with SLICE


Need some help. Because of the nature of some libraries I have to call with ICE, I had to make a slice script this way:
interface jSockets
char* jclCommand(char* command);

Slice complained that it doesnt know "char*". How do I convert a char* to ::std::string and back? Is there another way?

Thanks for the help.



  • marc
    marc Florida
    You can convert an std::string to const char* with the c_str() function. And you can convert a const char* (or char*) to an std::string simply by passing the const char* as an argument to the std::string constructor.

    Note that this doesn't have anything to do with Ice, that's simply standard C++.
  • Hello Marc,

    Thanks for the info. I've been combing the internet for solutions and there are a lot of complicated ones. Your suggestion looks to be the simplest one. I'll implement it as soon as I get to the office tomorrow. ;)

    Oh, I do know that this isn't an ICE problem, but considering I'm primarily a VB programmer ... I acknowledge that I'm way out of my league. Unfortunately, our office doesn't have any C++ programmer, I'm doing ICE integration on my own time and all of my colleagues are VB programmers ... your site/forum is the only place I can discuss these issues I encounter while programming C++ with ICE.

    Thanks again.