[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] Pointer til void functioner



On Fri, 30 Mar 2001, Jarl Erik Gjessing wrote:

> Jeg ville gerne have en pointer som peger på en function, så hvis jeg
> vil kalde den et sted fra, så bruger jeg pointeren.
> 
> Dette fordi jeg vil have en rutine som ikke behøver at vide hvilken
> function som er aktiv, men bare kalder den.
> Det er nok mere addressen på functionen som pointeren skal pege på, da
> der kun vil være een af den samme hver gang.
> 
> Håber der er nogen der kan hjælpe.

Noget i den her stil:

void * func1 (void *) {
  printf("hejsa 1\n");
}

void * func2 (void *) {
  printf("hejsa 2\n");
}


struct ged {
  void * (func) (void *)
} functions [] = {
  func1,
  func2
}

int main () {
  ged[0].func(NULL);
  ged[1].func(NULL);
}

burde virke.

Totalt utestet, off the head.

Mads

-- 
Mads Bondo Dydensborg.                               sslug@sslug
If you aim the gun at your foot and pull the trigger, it's UNIX's job to 
ensure reliable delivery of the bullet to where you aimed the gun (in
this case, Mr. Foot). 
                               - Terry Lambert, FreeBSD-Hackers mailing list.



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *