Rubbish Character When Return ?
1 2 3 4 5 6
|
string result = str.substr( find_array1 + 1,find_array2 - 1 ).c_str();
cout << result.c_str();
return result.c_str();
}
|
My function
const char* get_value_cstr(fstream &fin)
takes fstream as you can see.The cout << here produces a legit string. (means all readable).
but I return the same thing as right-operand of cout <<
and call it outside the function
cout << get_value_cstr(fin);
It justs shows rubbish characters,I don't know why.
That's because the c_str is invalidated when you delete the std::string result.
Wow.Cool !!!
Topic archived. No new replies allowed.