I have a program in C++ in which all the input into the program has underscores('_') instead of spaces. I'm trying to replace all the underscores which spaces(' '). I tried using std::replace but I keep getting errors, I'm not sure where I'm getting it wrong.
int main()
{
string j = "This_is_a_test";
j = std::replace( j.begin(), j.end(), '_', ' ');
// I'm trying to get: This is a test from 'j',
}
This is returning an error when I try compiling:
conversion from
void' to non-scalar type
std::basic_string, std::allocator >' requested