// // // // // Lab. Calcolo II - Esempio di codice // // // // // // // // Example code: Very simple stringstream usage. (20060728 prelz@mi.infn.it) #include <iostream> #include <iomanip> #include <sstream> int main(int argc, char *argv[]) { std::istringstream s_pi("3.1415926"); double pi; s_pi >> pi; std::cout << "The numeric value of PI is " << std::setprecision(20) << pi << std::endl << std::endl ; for (int i=1; i<=10; ++i) { std::ostringstream result; result << "Very smart counting program. Count == " << std::setw(2) << i << std::endl; std::cout << result.str() ; } return 0; }