I'm writing some code which should use math function (from math.h) chosen by user. I have something like
printf("If you want to use sin, press 's'\n"
"If you want to use cosh, press 'c'\n");
do choice = getchar();
while (choice != 's' && choice != 'c');
How to store the function user chose? I would like to have it in some variable fun
and then just use it in computation by writing fun(x)
, but have no idea how to do this. Please, help!