As you should have noticed when you read the manual on c_str(), but didn't, the result of c_str() is not modifiable, so any attempt to add something at the end is doomed to failure. Also, when C++ says const, it means it, so it laughs at your attempt to remove the const condition.

Since c_str() is not modifiable, you have to add rpg to the string filenameo itself. And if you don't plan to keep the name around, then there's no good reason to not just put the call in the constructor (and it's what people will expect, too), like so:
Code:
std::ofstream output(filenameo.c_str());