to_string is not a member of std, says g++ (mingw)

前端 未结 13 1153
不思量自难忘°
不思量自难忘° 2020-11-22 05:41

I am making a small vocabulary remembering program where words would would be flashed at me randomly for meanings. I want to use standard C++ library as Bjarne Stroustroup t

13条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 06:01

    As suggested this may be an issue with your compiler version.

    Try using the following code to convert a long to std::string:

    #include 
    #include 
    #include 
    
    int main() {
        std::ostringstream ss;
        long num = 123456;
        ss << num;
        std::cout << ss.str() << std::endl;
    }
    

提交回复
热议问题