摘要:
int FormatString(char* buffer,int buflen,char* format,...){ va_list args; va_start(args, format); int len = _vsnprintf(buffer, buflen, format, args); va_end(args); return len;}调用方式 char buffer[512]; FormatString(buffer,sizeof(buffer),"{\"key\":\"%d\"}",1); printf(buffer 阅读全文
摘要:
1:当无法列出传递函数的所有实参的类型和数目时,可用省略号指定参数表void foo(...);void foo(parm_list,...);2:函数参数的传递原理函数参数是以数据结构:栈的形式存取,从右至左入栈.eg:#include <iostream>void fun(int a, ...){int *temp = &a;temp++;for (int i = 0; i < a; ++i){cout << *temp << endl;temp++;}}int main(){int a = 1;int b = 2;int c = 3;in 阅读全文