标签:style snprintf char pre tput try erro ace error
#include <iostream> #include <cstdio> #include <cstdarg> #define LEN_MSG_BUFFER 128 using namespace std; void Message(int nLevel, const char *szFormat, ...) { char* szData = new char[LEN_MSG_BUFFER](); try { va_list args; va_start(args, szFormat); vsnprintf(szData, LEN_MSG_BUFFER, szFormat, args); va_end(args); } catch( ... ) { cout << "Error ..." << endl;} cout << szData << endl; delete[] szData; } int main() { Message(1,"Messages(%s), Code(%d).", "Test ‘...‘ .", 0); //system("pause"); return 0; } //OUTPUT: Messages(Test ‘...‘ .), Code(0).
标签:style snprintf char pre tput try erro ace error
原文地址:http://www.cnblogs.com/wjshan0808/p/6985644.html