Again, this is contrived because it begs the question, "what are you actually trying to do, besides just operate on a C++ stringstream"? In order to come up with a realistic alternative, the purpose of the string stream is needed.
Originally Posted by manasij7479
So I did something that I think sticks closely to what you did. I replaced <stringstream> with <cstdio>, commented out 7 lines in main and added 6.
Obviously, this is a bit silly: if you are working in C++, you might as well use C++ features, but I think it does demonstrate that the task you use as an example is no simpler or easier in C++ than it is in C (so the place this would require "at least 30 lines" is...mythical):
using namespace std;
// stringstream my_stream(ios::in|ios::out);
std::string dat("Hey, I have a double : 74.79 .");
const char *str = dat.c_str();
int len = dat.length() - 7;
str += len;
sscanf(str, "%lf", &val);
val = val*val;
// std::string new_val = my_stream.str();
sprintf(new_val, "%s%.2lf", dat.substr(0, len).c_str(), val);
Hey, I have a double : 5593.54