Is there an equivalent to CString Format in std::string ?
-
You have a number of choices. Two spring immediately to mind: 1. Use
ostringstream
. 2. Use Boost's[^] Format[^] library. Example using the first:#include <string>
#include <sstream>
#include <iostream>
int main(int argc, char* argv[])
{
using namespace std;
ostringstream oss;
const int one = 1;
const int two = 2;
oss << one << " + " << two << " is " << one+two;
cout << oss.str() << endl;
return 0;
}Examples of the second can be found at the link provided. I'd go for the second approach.
Steve
-
One way is convert std::string to CString using marshalling
-
You have a number of choices. Two spring immediately to mind: 1. Use
ostringstream
. 2. Use Boost's[^] Format[^] library. Example using the first:#include <string>
#include <sstream>
#include <iostream>
int main(int argc, char* argv[])
{
using namespace std;
ostringstream oss;
const int one = 1;
const int two = 2;
oss << one << " + " << two << " is " << one+two;
cout << oss.str() << endl;
return 0;
}Examples of the second can be found at the link provided. I'd go for the second approach.
Steve
-
One way is convert std::string to CString using marshalling