aspects. here is the example code:
/* C++ Primer - 4/e
*
* Example from Section 8.5 - sstream
*
*/
#include <iostream>
#include <sstream>
int main()
{
int i = 512;
int j = 400;
std::ostringstream format_int;
std::cout << "changing ints to strings\n" << std::endl;
format_int << "i = " << i << "\n"
<< "j = " << j << "\n";
std::cout << "done.... printing output..\n\n"
<< format_int
<< std::endl;
/* changing back to int */
std::cout << "changing back to int" << "\n\n"; std::istringstream
format_input(format_int.str());
std::string get_back;
format_input >get_back >i
std::cout << i>get_back >j;
<< "\t"
<< j
<< std::endl;
return 0;
}
--------- OUTPUT --------------
~/programming/c++ $ g++ -ansi -pedantic -Wall -Wextra 8.5.cpp
~/programming/c++ $ ./a.out
changing ints to strings
done.... printing output..
0x7fff863f3058
changing back to int
512 400
~/programming/c++ $
I do not get the output, the int vales are not converted to strings, i
just got a memory address. I do not even understand the mechanics of
"format_int" here, Where exactly that thing exists ? (I mean, fstream is
used to handle files which are stored oon hard-disk and cin and cout
handle the terminal IO. What exactly that format_int handles ?)