1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| [root@localhost ~]
void WriteLog(const char *format, ...) { char buff[2048]; const int size = sizeof(buff);
va_list args; va_start(args, format); vsnprintf(buff, size, format, args); va_end(args);
printf(buff); }
int main() { printf( "linux:[%f][%s][%d][%zd][%4d]\n", 1/3.0, "hello", 1992, 0x00FFFFFFFFFF, 42); WriteLog("linux:[%f][%s][%d][%zd][%4d]\n", 1/3.0, "hello", 1992, 0x00FFFFFFFFFF, 42);
return 0; }
|