2012-03-25 10 views

Antwort

15

es Genau wie Sie setzen in jedes andere Feld:

struct example { 
    int x; 
    DoRunTimeChecks y; 
}; 

void Function(void) 
{ 
} 

struct example anExample = { 12, Function }; 

auf dem Feld zuzuordnen:

anExample.y = Function; 

die Funktion aufzurufen:

anExample.y(); 
4
#include <stdio.h> 

typedef void (*DoRunTimeChecks)(); 

struct func_struct { 
    DoRunTimeChecks func; 
}; 

void function() 
{ 
    puts("hello"); 
} 

int main() 
{ 
    struct func_struct func_struct; 
    func_struct.func = function; 
    func_struct.func(); 
    return 0; 
} 
Verwandte Themen