User manual

Table Of Contents
234
mikoC PRO for PIC32
MikroElektronika
Ellipsis (‘...’) Operator
The ellipsis (‘...’) consists of three successive periods with no whitespace intervening. An ellipsis can be used in
the formal argument lists of function prototypes to indicate a variable number of arguments, or arguments with varying
types. For example:
void func (int n, char ch, ...);
This declaration indicates that func will be dened in such a way that calls must have at least two arguments, int and
char, but can also have any number of additional arguments.
Example:
#include <stdarg.h>
int addvararg(char a1,...){
va_list ap;
char temp;
va_start(ap,a1);
while( temp = va_arg(ap,char))
a1 += temp;
return a1;
}
int res;
void main() {
res = addvararg(1,2,3,4,5,0);
res = addvararg(1,2,3,4,5,6,7,8,9,10,0);
}