I need to pass part of a string to function:
string original_string="my_name_original";
string wanted_string (original_string,7); //take "my_name" only
my_func(wanted_string, other_var);
//func:
void my_func(string wanted_string, int other_var);
This doesn't seem to work, the compiling was OK but the passed "wanted_string" is empty; When pass char*, it works fine:
char* original_string="my_name_original";
my_func(wanted_string, other_var);
//func:
void my_func(char* wanted_string, int other_var);
Questions:
(1) How to get "my_name" from char* original_string?
(2) Is it true that string can NOT be passed?