You are on page 1of 1

Practice with String Buffers

#include <sstream> #include <fstream> #include <iostream> using namespace std; int main() { int x; float f; string s = "3.7"; istringstream is(s); is >> x >> f; cout << x << " " << f << endl; string line = "Sink or Swim!!"; istringstream is2(line); string word1, word2; is2 >> word1; is2 >> word2 >> word2; cout << word1 << " " << word2 << endl; ostringstream os (s, ios::out); os << 77 << hex << 77 << endl; cout << os.str() << endl; cout << s << endl; return 0; }

Sample Run

3 0.7 Sink Swim!! 774d 3.7

You might also like