Easiest way to convert int to string in C++

后端 未结 28 1749
甜味超标
甜味超标 2020-11-21 06:42

What is the easiest way to convert from int to equivalent string in C++. I am aware of two methods. Is there any easier way?

(1)



        
28条回答
  •  情歌与酒
    2020-11-21 07:19

    This worked for me -

    My code:

    #include 
    using namespace std;
    
    int main()
    {
        int n = 32;
        string s = to_string(n);
        cout << "string: " + s  << endl;
        return 0;
    }
    

提交回复
热议问题