You need to provide your own memory for sprintf
. Also, don't use sprintf
, but rather snprintf
:
char buf[1000] = {0};
snprintf(buf, 999, ....);
Alternatively you can allocate memory dynamically:
char * buf = new char[BUFSIZE];
snprintf(buf, BUFSIZE-1, ...);
/* ... */
delete[] buf;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…