Hi,
I'm trying to figure out how to take the text "Say ", and combine it with the value of a float variable (99.12), so that I end up with a C style string that looks like "Say 99.12".
Does anyone know how I'd go about doing this? I would use C++ style strings but I'm trying to mod Quake 2, and basically this function accepts a C style string, like this:
void qbSynchConsole(char *);
So does anyone know what's wrong with my little example program that I made as an experiment? It crashes but I don't know why. Any help would be highly appreciated.
Code:#include <iostream> #include <cstring> using namespace std; int main() { char *char1 = NULL; char *char2 = NULL; float a = 99.12; int dec,sign; char1 = "Say "; char2 =_fcvt(a,2,&dec,&sign); strcat ( char1, char2 ); cout << "char1 = " << char1; return 0; }