You cannot add a pointer to a character and such an integer (you can, but it will not do what you expect).
First you need to convert x to string. You can either do this outside of the C range using the itoa function to convert an integer to a string:
char buf[5]; itoa(x, buf, 10); s += buf;
Or the STD path using sstream:
#include <sstream> std::ostringstream oss; oss << s << x; std::cout << oss.str();
Or directly in the cout line:
std::cout << text << x;
Mahmoud Al-Qudsi
source share