a the simplest way is to use a


A: The simplest way is to use a stringstream:

#include

#include

#include

using namespace std;

string itos(int i) // convert int to string

{

stringstream s;

s << i;

return s.str();

}

int main()

{

int i = 127;

string ss = itos(i);

const char* p = ss.c_str();

cout << ss << " " << p << "\n";

}

Naturally, this technique works for converting any type that you can output using << to a string.

 

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: a the simplest way is to use a
Reference No:- TGS0217692

Expected delivery within 24 Hours