What on earth do you need to do that for?
You can extend algorism's example so that you can refer to each function using its name, for example
Code:
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
typedef void function_t(void);
void func1(void) { printf("func1() called\n"); }
void func2(void) { printf("func2() called\n"); }
void func7(void) { printf("func7() called\n"); }
static const struct {
const char *const name;
function_t *const func;
} functab[] = {
{ "func1", func1 },
{ "func2", func2 },
{ "func7", func7 },
};
#define FUNCTAB_SIZE (sizeof functab / sizeof functab[0])
static function_t *find_function(const char *const name)
{
size_t i = FUNCTAB_SIZE;
while (i-->0)
if (!strcmp(functab[i].name, name))
return functab[i].func;
return NULL;
}
int main(int argc, char *argv[])
{
int arg;
if (argc < 2 || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
size_t i;
fprintf(stderr, "\n");
fprintf(stderr, "Usage: %s [ -h | --help ]\n", argv[0]);
fprintf(stderr, " %s function ...\n", argv[0]);
fprintf(stderr, "\n");
fprintf(stderr, "Recognized functions:\n");
for (i = 0; i < FUNCTAB_SIZE; i++)
printf("\t%s\n", functab[i].name);
fprintf(stderr, "\n");
return EXIT_FAILURE;
}
for (arg = 1; arg < argc; arg++) {
function_t *const func = find_function(argv[arg]);
if (!func) {
fprintf(stderr, "%s: No such function.\n", argv[arg]);
return EXIT_FAILURE;
}
func();
fflush(stderr);
}
return EXIT_SUCCESS;
}
and POSIX.1-2001 even provides dlopen() and dlsym() (part of the dynamic loader, so you'll need to link against it by adding -ldl at compile time) that can be used to examine the symbols in the program and even load new code (plugins) to the current program. I'm sure Windows has something similar, too.
None of these specify what the function parameters are, and what the function returns, if anything. Those are things the program has to know in order to call the function, as there just is no way to find them out at run time. (Above, you could add a field, say type, to the functab, to identify which kind of function (parameters and return type if any) the function refers to.)
None of those help with algebraic expressions like 2*x*sin(x*M_PI/180.0). For those, you need an algebraic expression parser -- basically, a (non-simple) calculator. It is a relatively common advanced exercise.