Why would I need to explicitly cast number 0
to char
before appending it to string using string::operator+
?
using namespace std;
int main()
{
string s = "";
s += 65; // no compile error
s += (char)0; // requires explicit cast
//s += 0; // compile error
return 0;
}
Update to clarify: My goal has been to append one byte (containing whatever value, including zero) to an existing array of bytes.