Assuming the OP isn't optimizing for some tiny embedded system, and is already using sstream rather than implementing his own itoa() to convert the integer pageNo to a string, why not simply stick with stringstream:
Code:
...
std::stringstream ss; // he already has the equivalent of this in his code
int pageNo = 31; // he already has the equivalent of this in his code
ss << "page" << pageNo << ".html"; // he already has 'ss << pageNo;' in his code
std::string s;
ss >> s;
out.open(s.c_str());
...
or, if you object to the overhead of std::string (and he's not already using it someplace anyway):
Code:
...
std::stringstream ss; // he already has the equivalent of this in his code
int pageNo = 31; // he already has the equivalent of this in his code
ss << "page" << pageNo << ".html"; // he already has 'ss << pageNo;' in his code
char cs[5];
const char* cp = cs;
ss >> cs;
out.open(cp);
...
Now the only added overhead is a 5-byte char array (assuming his page numbers are no more than 4 digits) and a const char*.