How can I combine multiple char's to make a string?
c++, char, string
Solution
You can concatenate chars to a `std::string`, you just need one of the operands to be a `std::string`, otherwise you are adding integers.
std::string signature = std::string() + char_array[index+1] + '/' + char_array[index+2];
Note that this only works if either the first or second operand in the chain is a `std::string`. That will result in the first call to `operator+` returning a `std::string`, and the rest will follow suit. So this doesn't give the expected results:
std::string signature = char_array[index+1] + '/' + char_array[index+2] + std::string();
Problem
I am doing string parsing and essentially what I would like to do is something like this: ``` string signature = char[index+1] + '/' + char[index+2]; ``` BUT you can't do string concatenation on char's so that brings me to this question, how can I simulate concatenation on char's? I know that the string library in C++ has append but I don't think that works for my case. Any ideas?