Convert single character string to char without use of an array
I'm trying to convert a single character string into a char. I would rather not have to use an array to try to keep the code simpler.
Is there a method for changing the string into an array or do I just need to use a char array regardless?
Here is a rough copy of how I'm doing this conversion now with an array (I know it's not perfect).
1 2 3 4
|
arr = new char[string.length()];
std::strcpy(arr, string.c_str());
|
1 2
|
assert(string.size() == 1);
char character = string[0];
|
Topic archived. No new replies allowed.