assigning int variable to string

Hello, I am a beginner in c++. I have a problem on assigning a variable(integer) into string variable. In this case, customercoffee is a string and order is an integer. Please help!!! Thank you.

 
  customercoffee = order + " Expresso";
If you have access to C++11.
http://www.cplusplus.com/reference/string/to_string/

Otherwise use stringstream. For example

1
2
3
4
5
int x = 32;

stringstream SS;
SS << x;
string y = SS.str();


http://www.cplusplus.com/reference/sstream/stringstream/
Topic archived. No new replies allowed.