The class ostringstream is often used for combining many number chains and transforming it into string, such as itoa() or sprintf( ... , "%f" , ...) in C standard library
The following is an example of this class.
int main() {
ostringstream myO;
myO << 12 << 8; // myO = "128"
cout << myO.str() << endl;
return 0;
}
Result>
128
To clear myO up, use myO.str("")
Wait! if you want to use the string contained in myO instance at the time of calling the constructor of ifstream instance, for example, ifstream inf (myO.str()), we cannot miss a serious (and terrible) mass of compile message. To avoid it, we need one more method c_str().
ifstream inf (myO.str().c_str())