How do you convert an int into a string in c++
问题 I want to convert an int to a string so can cout it. This code is not working as expected: for (int i = 1; i<1000000, i++;) { cout << "testing: " + i; } 回答1: You should do this in the following way - for (int i = 1; i<1000000, i++;) { cout << "testing: "<<i<<endl; } The << operator will take care of printing the values appropriately. If you still want to know how to convert an integer to string, then the following is the way to do it using the stringstream - #include <iostream> #include