String Streams in C++

#include <iostream>
#include <sstream>
#include <string>
using namespace std;

int main()
{
    stringstream sStream{"Hello World!"};
    cout << sStream.str() << endl;
    stringstream ss;
    ss << "Hi There";
    cout << ss.str() << endl;
    string s = ss.str();
    cout << s << endl;

    char c = 'B';
    int i = 40;
    double d = 90.50;
    stringstream ss2;
    ss2 << c << ' ' << i << ' ' << d;
    cout << ss2.str();

    return 0;
}

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *