c_string vs string

Pages: 12
Well, looking at the reference, you're supposed to send the script line by line, so all is fine.
You have an array of char* in the example, and you have an array of char* now. Nothing changed.
Last edited on
I am sorry, I don't understand... I can't even compile a
1
2
3
4
5
6
7
8
9
10
11
const char** cscript1[] = 
{
	"reset",
	cstr_time,
	cstr_temp,
	"SiO2(aq) = 1 umolal",
	"react 5000 g Quartz",
	"kinetic Quartz rate_con = 2.e-15 surface = 1000",
	"go",
	""
};

... ? It has to be a char* cscript1[], no?
Erm yes, why did you even change that? You really should revise arrays, C strings and pointer arithmetic. I could try explaining, but I have no idea what you know and what you don't and why you think this could possibly work (or if you even care).
Last edited on
I do care ;)
Unfortunately I don't know much about arrays and C strings indeed.
Though I do know that this doesn't work, since the script has to be and stay a char* script1[]... but this is why I don't fully understand that you told me
Well, this is how it should look like:
char** script1 = const_cast<char**>(cscript1);
I got it!!
I guess I just understood where you wanted me to use the const_cast...
I need to use it right after my
1
2
string str_time="time begin = 0 days, end = "+time_step+" days";
const char* ccstr_time=str_time.c_str(); 

and this way, it works perfectly...
I'm not really sure if we're talking about the same thing, but there are two possibilities here of how you can use const_cast. Either directly on the C strings returned by c_str() or on the entire array (or later when you call SendCommand, for that matter).
Last edited on
Topic archived. No new replies allowed.
Pages: 12