void test1(char *pkt, char *cmd, char *arg, ...) { char *fmt; va_list ap; va_start(ap, arg); *pkt = START; *(pkt += vsprintf(cmd = ++pkt, fmt = cmd, ap)) = SEP; for (char *ptr = strchr(fmt, '%'); ptr++; ptr = strchr(ptr, '%')) (void)((*ptr == '%' && ptr++) || va_arg(ap, void *)); *(pkt += vsprintf(arg = ++pkt, fmt = arg, ap)) = END; va_end(ap); }