如何使用变量调用函数

How to call a function with a variable?

本文关键字:函数 调用 变量 何使用      更新时间:2023-10-16

你好,所以我想用这样的变量调用一个函数,例如

void Test(){
    printf(":P");
}
void Tests(int foo){
}
void Tester(unsigned int r){
   int r = Test(r);
   /*Just an example*/ 
   Trace(r);
}

看起来你需要这样的东西:

#include <stdio.h>
void Test()
{
    printf(":P");
}
int main()
{
    void (*foo)();
    foo = &Test;
    (*foo)();
    return 0;
}

请在您的问题中添加详细信息。现在很难帮助你。