下面Keil用到stdarg.h头文件:-程序例子--------------------------#include#includeunsignedcharmax(unsignedcharn,...){unsignedcharmax=0,temp;va_listpStack;...
下面Keil用到stdarg.h头文件:
-程序例子--------------------------
#include
#include
unsigned char max( unsigned char n ,...)
{ unsigned char max = 0 , temp ;
va_list pStack;
va_start( pStack , n );
while( n-- ) /
{
temp = va_arg( pStack , unsigned char ) ;
max = ( max > temp ? max : temp ) ;
}
va_end( pStack ) ;
return n ;
}
void main( void )
{ unsigned char n;
n=max(32,0xE4,0x01,0x01,0x00,0x05,0x0F,0x00,0x2F,0x00,0x45,0x00,0x54,0x00,0x67,0x00,0x7C,0x00,0xCB,0x00,0x8C,0x00,0x99,0x00,0xA8,0x00,0xBA,0x00,0xC5,0x00,0xCB,0x00);
while(1);
}
------------------------------
max多参数传入,若参数在32个数量内可以正常编译和运行。若参数超过33个就会出现错误,提示TEST.C(24): error C208: '_max': too many parameters。
由于我用的程序会经常用到大于33个的参数传递函数中进行处理。
请高手求解。
展开