вторник, 23 апреля 2019 г.

Перевод числа в строку и наоборот в С++

#include <iostream>
#include <sstream>
using namespace std;
int main()
{
    string s="12";
    istringstream in_str;
    in_str.str(s);
    int k;
    in_str >> k;
    cout<<k*2<< endl;

    ostringstream out_str;
    int N = 123;
    out_str << N;
    s = out_str.str()+" year";
    cout<<s;
    out_str.str(""); // clear stringstream
}



Комментариев нет:

Отправить комментарий