且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从int转换为char *?

更新时间:2023-11-11 23:18:58


  • 在C ++ 11中,使用 std :: to_string as:

    std::string s = std::to_string(number);
    char const *pchar = s.c_str();  //use char const* as target type
    


  • 're done is just fine,except use const as:

    char const* pchar = temp_str.c_str(); //dont use cast