如何让用户输入调用函数C

Kyl*_*yle 3 c

我如何使用变量(我将从用户输入获得)来调用函数?

char user_function[10];
scanf("%s", user_function);
user_function(); //Calls the function named user_function that the user typed
Run Code Online (Sandbox Code Playgroud)

(没有像这样的东西)

char user_function[10];
scanf("%s", user_function);
if( strcmp(user_function, 'printf()'))
printf();
Run Code Online (Sandbox Code Playgroud)

Joh*_*136 6

你不能.

在某些时候,你必须查看字符串内容并使用它们来调用特定的函数.

你可以通过对函数指针执行类似查找表/字符串的哈希映射来"隐藏它",但最后它仍然只是"查看字符串并决定调用什么"