Convert int to string in C++. Following program converts an int to string in C++.
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
string int_to_string(const int& port) {
stringstream ss;
ss << port;
return ss.str();
}
int main() {
int port = 114;
cout << int_to_string(port) << endl;
}
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
string int_to_string(const int& port) {
stringstream ss;
ss << port;
return ss.str();
}
int main() {
int port = 114;
cout << int_to_string(port) << endl;
}
No comments:
Post a Comment