【C++ 字串處理 #6】C++ 轉 string 的好工具 to_string()

前言

我們可以使用 std::to_string,把變數轉為 string 的型態。

範例程式碼

#include <iostream>

using namespace std;

int main(){
    string s = to_string(123);
    s += "test";
    cout << s << endl;
    return 0;
}

search words

  • int to string C++

Reference

使用 Hugo 建立
主題 StackJimmy 設計