|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [gameprogrammer] Re: How to assign a numeric variable to an std::string?
I ended up doing this, which is more flexible:
std::string query;
query+=FormatString("%i", 5);
// FormatString.cpp
#include "FormatString.h"
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#if defined(__GNUC__)
#define _vsnprintf vsnprintf
#endif
char * FormatString(const char *format, ...)
{
static int textIndex=0;
static char text[4][8096];
va_list ap;
va_start(ap, format);
if (++textIndex==4)
textIndex=0;
_vsnprintf(text[textIndex], 8096, format, ap);
va_end(ap);
text[textIndex][8096-1]=0;
return text[textIndex];
}
Brian wrote:
On Jan 11, 2008 9:36 PM, Kevin Jenkins <gameprogrammer@rakkar.org> wrote:float f=5; std::string myStr; myStr << f;Use std::stringstream, or a wrapper thereof such as boost::lexical_cast. --------------------- To unsubscribe go to http://gameprogrammer.com/mailinglist.html --------------------- To unsubscribe go to http://gameprogrammer.com/mailinglist.html
|
|