Some common usage

Data type conversion(数据类型的转换)

For example:

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string       a = "521", b;
    int          c, d = 1314;
    stringstream x, y;
    x << a;   y << d;
    x >> c;   y >> b;
    cout << a << b << endl << c << d << endl;
    cout << "The size of b is " << sizeof(b) << "\nThe size of c is " << sizeof(c) << endl;
}

Output:

5211314
5211314
The size of b is 24
The size of c is 4

In this case,we transform a string to int and an int to string through stringstream.

Can be used to split strings separated by spaces etc.(可以分割被空格分割的字符串)

For example:

#include <bits/stdc++.h>
using namespace std;
int main()
{
    string       s = "521 1314",mid;
    stringstream x(s);
    while (x >> mid)
    {
        cout << mid << endl;
    }
}

Output:

521
1314

This part is always useful in some type.

Official explanation

CPP: https://www.cplusplus.com/reference/sstream/stringstream/

As far as I know,If you can grasp the common usage,it's enough in ACM.