`

va_list使用的简单范例

阅读更多
#include <stdarg.h>

#include <iostream>

using namespace std;

void TestPrint(char *fmt, ...)
{
	va_list args;                
	va_start(args, fmt);
	
	while(fmt!="e")               
	{
		cout<<fmt<<endl;
		fmt=va_arg(args,char*);
	}
	//注意,这里va_list并不以NULL为结束,所以不要进行循环的找值
        //使用时应以找到某个值为目标进行操作
	va_end(args);
}

int main(int argc, char **argv)
{
	TestPrint("a","b","c","d");

	return 0;	
}
分享到:
评论
1 楼 lin_style 2008-05-12  
output
a
b
c
d
        B
8Z@

‰ÁëX1É‹ƒ„#

相关推荐

Global site tag (gtag.js) - Google Analytics