Under c++ you can use ostringstream :
#include<iostream>
#include <sstream>
int main() {
std::ostringstream os;
typedef unsigned long DWORD;
DWORD dw1 = 1;
DWORD dw2 = 2;
DWORD dw3 = 2;
os << dw1 << "," << dw2 << "," << dw3 << std::endl;
std::cout << os.str();
// os.str() returns std::string
return 0;
}
your sample code indicates that you might prefer C solution like:
char str[256];
sprintf(str, "%ld %ld %ld", dw1, dw2, dw3);
std::cout << str; // this is of course c++ part :)
ps. I have tested this with g++4.8