I need to pass variable argument to another function. The problem is that this argument is an function and i have no idea how to determine the type of funtion. For example i have function: char(*)char(c), how to read it by va_arg?
void process(const char* typ ...)
{
char c;
va_list ap;
va_start(ap, typ);
while (*typ != 0)
{
switch (*typ)
{
case'p':
//change(va_arg(ap, char*), va_arg(ap, char(*)char(c)));
case 'f':
//filterr(va_arg(ap, char*), va_arg(ap, bool(*)char));
case 's':
char* a = va_arg(ap, char*);
char* b = va_arg(ap, char*);
encrypt(a, b);
break;
}
}
}
char changeToUppear(char c) {
return (c >= 'a' and c <= 'z') ? c - 32 : c;
}
bool leaveLowercase(char c) {
return (c < 'a' or c>'z');
}
vprintf()and its siblings, for example.process("pfs",s1,changeToUppear,s2,leaveLowercase,s3,"TAJNE");over the more usualmap(s1, toUpper); filter(s2, isLower); encrypt(s3, "TAJNE");, which gives you the benefit of type safety?`