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

前端 未结 13 1129
不思量自难忘°
不思量自难忘° 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:05

    This happened to me as well, I just wrote up a quick function rather than worrying about updating my compiler.

    string to_string(int number){
        string number_string = "";
        char ones_char;
        int ones = 0;
        while(true){
            ones = number % 10;
            switch(ones){
                case 0: ones_char = '0'; break;
                case 1: ones_char = '1'; break;
                case 2: ones_char = '2'; break;
                case 3: ones_char = '3'; break;
                case 4: ones_char = '4'; break;
                case 5: ones_char = '5'; break;
                case 6: ones_char = '6'; break;
                case 7: ones_char = '7'; break;
                case 8: ones_char = '8'; break;
                case 9: ones_char = '9'; break;
                default : ErrorHandling("Trouble converting number to string.");
            }
            number -= ones;
            number_string = ones_char + number_string;
            if(number == 0){
                break;
            }
            number = number/10;
        }
        return number_string;
    }
    
    0 讨论(0)
提交回复
热议问题