溫馨提示×

c++怎么把數字轉換成字符串

c++
小億
197
2024-02-19 11:51:20
欄目: 編程語言

在C++中,可以使用std::to_string()函數將數字轉換為字符串。例如:

#include <iostream>
#include <string>

int main() {
    int num = 123;
    std::string str = std::to_string(num);
    std::cout << "The number as a string is: " << str << std::endl;
    
    return 0;
}

上面的代碼中,將整數num轉換為字符串str,然后輸出轉換后的字符串。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女