You should be using ostringstream (in <sstream>) rather than ostrstream these days. ostrstream has been deprecated since C++98 (i.e. 15 years!)
But the correct answer is 2.79, yes?
Andy
value = 2.79
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
#include <iomanip> // for setprecision
#include <sstream> // for ostringstream
usingnamespace std;
int main()
{
ostringstream out;
float fvalue = 2.7889f; // f suffix as it's a float value
out << setprecision(3);
out << "value = ";
out << fvalue;
cout << out.str() << endl;
return 0;
}